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); }
/// <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); } }