1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Threading.Tasks;
- using WingServerCommon.Service;
- using WingServerCommon.Config;
- using WingServerCommon.Config.Parameters;
- using WingInterfaceLibrary.Interface;
- using WingInterfaceLibrary.Interface.DBInterface;
- using WingInterfaceLibrary.Request.Notification;
- using System.Collections.Generic;
- using WingInterfaceLibrary.DTO.Common;
- using JsonRpcLite.Services;
- using WingInterfaceLibrary.Enum;
- using WingInterfaceLibrary.Notifications;
- namespace WingNotificationModule.Service
- {
- /// <summary>
- /// 通知服务
- /// </summary>
- public class NotificationService : JsonRpcService, INotificationService
- {
- private NotificationServer _notificationServer;
- private IAuthenticationService _authenticationService;
- private IStorageDBService _storageDBService;
- /// <summary>
- /// 构造函数
- /// </summary>
- public NotificationService()
- {
- var host = ConfigurationManager.GetParammeter<StringParameter>("Notification", "Host");
- var maxQueueCount = ConfigurationManager.GetParammeter<IntParameter>("Notification", "MaxQueueCount").Value;
- _notificationServer = new NotificationServer(host.Value, maxQueueCount);
- }
- public override void Load(JsonRpcClientPool jsonRpcClientPool)
- {
- base.Load(jsonRpcClientPool);
- _authenticationService = GetProxy<IAuthenticationService>();
- _notificationServer.Start(_authenticationService);
- _storageDBService = GetProxy<IStorageDBService>();
- }
- /// <summary>
- /// 发送通知,等待发送完消息返回是否成功
- /// </summary>
- /// <param name="request">发送通知请求</param>
- /// <returns>是否成功</returns>
- /// <value>true</value>
- public async Task<bool> SendMessageAsync(SendNotificationRequest request)
- {
- return await _notificationServer.SendMessageAsync(request);
- }
- /// <summary>
- /// 发送通知,消息进入发送队列,返回是否成功进入发送队列
- /// </summary>
- /// <param name="request">发送通知请求</param>
- /// <returns>是否成功</returns>
- /// <value>true</value>
- public async Task<bool> PostMessageAsync(SendNotificationRequest request)
- {
- return await _notificationServer.PostMessageAsync(request);
- }
- public async Task<bool> BroadcastMessageAsync(BroadcastNotificationRequest request)
- {
- return await _notificationServer.BroadcastMessageAsync(request);
- }
- public async Task<string> OpenNotifyQueueAsync(OpenNotifyQueueRequest request)
- {
- return _notificationServer.OpenNotifyQueueAsync(request.Module);
- }
- public async Task<bool> CloseNotifyQueueAsync(CloseNotifyQueueRequest request)
- {
- return _notificationServer.CloseNotifyQueueAsync(request.MsgQueueId);
- }
- }
- }
|