Пример #1
0
 /// <summary>
 /// Send message data to specific group collection in asynchronous mode.
 /// </summary>
 /// <param name="groupNameCollection">The group collection to receive the message.</param>
 /// <param name="messageData">The message data to be sent to group collection.</param>
 /// <param name="offset">The offset of the message data.</param>
 /// <param name="count">The count of bytes to be sent.</param>
 /// <param name="callback">The callback that will be called after sending.</param>
 /// <param name="state">The user defined state.</param>
 /// <param name="loopBack">True if the message returns to the sender; otherwise false. The default is false.</param>
 /// <returns>An System.IAsyncResult that references the asynchronous send.</returns>
 public IAsyncResult SendGroupMessageAsync(IEnumerable <string> groupNameCollection, byte[] messageData, int offset, int count, AsyncCallback callback, object state, bool loopBack = false)
 {
     if (_clientStatus != ClientStatus.Connected)
     {
         throw new Exception(Constants.ExMessageClientNotConnected);
     }
     if (groupNameCollection == null)
     {
         throw new Exception("the group name collection can not be null");
     }
     byte[] groupMessageData = GroupTransmitMessage.MakeGroupMessage(groupNameCollection, new ArraySegment <byte>(messageData, offset, count), loopBack);
     return(SendMessageAsync(groupMessageData, callback, state));
 }
Пример #2
0
 /// <summary>
 /// Send message data to specific group collection in synchronous mode.
 /// </summary>
 /// <param name="groupNameCollection">The group collection to receive the message.</param>
 /// <param name="messageData">The message data to be sent to group collection.</param>
 /// <param name="offset">The offset of the message data.</param>
 /// <param name="count">The count of bytes to be sent.</param>
 /// <param name="loopBack">True if the message returns to the sender; otherwise false. The default is false.</param>
 /// <returns>The number of bytes sent to the server.</returns>
 public int SendGroupMessage(IEnumerable <string> groupNameCollection, byte[] messageData, int offset, int count, bool loopBack = false)
 {
     if (_clientStatus != ClientStatus.Connected)
     {
         throw new Exception("the client is not connected");
     }
     if (groupNameCollection == null)
     {
         throw new Exception("the group name collection can not be null");
     }
     byte[] groupMessageData = GroupTransmitMessage.MakeGroupMessage(groupNameCollection, new ArraySegment <byte>(messageData, offset, count), loopBack);
     return(SendMessage(groupMessageData));
 }