Exemplo n.º 1
0
        public void Notify(string message, string userID, int msgLifeHour = 1)
        {
            byte[] buffer = Encoding.Default.GetBytes(message);
            var    arg    = new SocketSenderArgs()
            {
                ConnectID         = userID,
                Message           = message,
                MessageType       = SocketMessageType.Notification,
                OnSendComplete    = completeNotifyCallback,
                MessageFormatting = this.MessageFormatting,
                LifeHours         = msgLifeHour
            };

            CurrentSender.Enqueue(arg);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 向连接池中所有用户发送通知
 /// </summary>
 /// <param name="message"></param>
 public void Notify(string message, int msgLifeHour = 1)
 {
     foreach (var conn in currentPool.GetAll())
     {
         var arg = new SocketSenderArgs()
         {
             ConnectID         = conn.Key,
             Message           = message,
             MessageType       = SocketMessageType.Notification,
             OnSendComplete    = completeNotifyCallback,
             MessageFormatting = this.MessageFormatting,
             LifeHours         = msgLifeHour
         };
         CurrentSender.Enqueue(arg);
     }
 }