Ejemplo n.º 1
0
 public void SendMessage(IPEndPoint endPoint, Message message)
 {
     var sender = new Sender(endPoint, peerId) { RsaKeyStore = RsaKeyStore };
     sender.SendMessage(message,
         message is UserMessage ?
         (ulong)Interlocked.Increment(ref outgoingPacketIndex) : 0);
 }
Ejemplo n.º 2
0
 public void SendMessage(Message message)
 {
     lock (neighbors)
         foreach (var neighbor in neighbors)
         {
             if (message is UserMessage)
                 Interlocked.Increment(ref outgoingPacketIndex);
             foreach (var endPoint in neighbor.IpEndPoints)
             {
                 var sender = new Sender(endPoint, peerId) { RsaKeyStore = RsaKeyStore };
                 sender.SendMessage(message, message is UserMessage ? (ulong)outgoingPacketIndex : 0);
             }
         }
 }
Ejemplo n.º 3
0
 protected void OnMessageReceived(Message messageReceived)
 {
     var eventHandler = MessageReceived;
     if (eventHandler != null)
         eventHandler(new MessageReceivedEventArgs { MessageReceived = messageReceived });
 }
Ejemplo n.º 4
0
 public void SendBroadcastMessage(Message message)
 {
     var sender = new Sender(broadcastPort, peerId) {  RsaKeyStore = RsaKeyStore};
     sender.SendMessage(message, 0);
 }
Ejemplo n.º 5
0
 public void SendMessage(Message message, ulong packetIndex)
 {
     udp.Connect(ipEndPoint);
     var msg = (MessageVersion1)message;
     msg.Mac = new Mac(((IPEndPoint)(udp.Client.LocalEndPoint)).Address).MacAddress;
     msg.PeerId = peerId;
     msg.PacketIndex = packetIndex;
     var messageData = message.Serialize();
     if (RsaKeyStore != null)
     {
         msg.Signature = SignPackage(messageData);
         messageData = message.Serialize();
     }
     udp.BeginSend(messageData, messageData.Length, RequestCallback, null);
 }