Пример #1
0
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="messages"></param>
 protected void send(params string[] messages)
 {
     if (isClose == 0 && messages.Length != 0)
     {
         Monitor.Enter(messageLock);
         byte isSendMessage = this.isSendMessage;
         this.isSendMessage = 1;
         try
         {
             if (this.messages == null)
             {
                 this.messages = new collection <message>();
             }
             foreach (string message in messages)
             {
                 if (!string.IsNullOrEmpty(message))
                 {
                     this.messages.Add(new message {
                         Message = message
                     });
                 }
             }
         }
         finally
         {
             Monitor.Exit(messageLock);
             if (isSendMessage == 0)
             {
                 socket.WebSocketSend(this);
             }
         }
     }
 }
Пример #2
0
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="message"></param>
 private void send(message message)
 {
     if (isClose == 0)
     {
         Monitor.Enter(messageLock);
         byte isSendMessage = this.isSendMessage;
         this.isSendMessage = 1;
         try
         {
             if (messages == null)
             {
                 messages = new collection <message>();
             }
             messages.Add(message);
         }
         finally
         {
             Monitor.Exit(messageLock);
             if (isSendMessage == 0)
             {
                 socket.WebSocketSend(this);
             }
         }
     }
 }