示例#1
0
 public void BroadcastMessage(ITypedMessage typedMessage, ushort from, ushort except = 0xFFFF)
 {
     try
     {
         if (!typedMessage.GetMessageType().OnlyBroadcasted())
         {
             throw new DnmpException("Message is not broadcastable");
         }
         foreach (var client in realClient.ClientsById.Values.Where(x =>
                                                                    x.ParentId == realClient.SelfClient.Id || x.Id == realClient.SelfClient.ParentId))
         {
             if (client.Id == except)
             {
                 continue;
             }
             if (typedMessage.GetMessageType() == MessageType.DataBroadcast)
             {
                 client.DataBytesSent += typedMessage.GetBytes().Length;
             }
             SendReliableMessage(typedMessage, from, 0xFFFF, client.Id, client.EndPoint, MessageFlags.IsRedirected);
         }
     }
     catch (Exception)
     {
         if (realClient.CurrentStatus == DnmpClient.ClientStatus.Disconnecting ||
             realClient.CurrentStatus == DnmpClient.ClientStatus.NotConnected)
         {
             return;
         }
         throw;
     }
 }
示例#2
0
 public BaseMessage(ITypedMessage typedMessage, ushort sourceId, ushort destinationId, ushort realSourceId, ushort realDestinationId, Guid id = new Guid(), MessageFlags messageFlags = MessageFlags.None) :
     this(typedMessage.GetBytes(), typedMessage.GetMessageType(), sourceId, destinationId, realSourceId, realDestinationId, id, messageFlags)
 {
 }