Exemple #1
0
 public override void RelayClientMessage(Guid entityID, Guid clientID, int channel, byte[] data)
 {
     if (GenerationNumber == Simulation.Stack.NewestRegisteredSDSGeneration)
     {
         InteractionLink.Relay(entityID, clientID, channel, data, GenerationNumber);
     }
 }
Exemple #2
0
 private void Listen()
 {
     try
     {
         while (true)
         {
             Console.WriteLine("Listener: Waiting for next connection... ");
             TcpClient client = server.AcceptTcpClient();
             try
             {
                 IPEndPoint addr = (IPEndPoint)client.Client.RemoteEndPoint;
                 Address    host = new Address(Dns.GetHostEntry(addr.Address).HostName, addr.Port);
                 //Link link = linkLookup?.Invoke(host);
                 //if (link == null)
                 {
                     var lnk = InteractionLink.Establish(client, linkLookup);
                     OnNewInteractionLink?.Invoke(lnk);
                     continue;
                 }
                 //Simulation.FindLink(host.ID);
                 //link.SetPassiveClient(client);
             }
             catch (Exception ex)
             {
                 Console.Error.WriteLine(ex);
             }
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex);
     }
     return;
 }
Exemple #3
0
 public void OnMessageCommit(Address clientAddress, ClientMessage message)
 {
     if (!clientAddress.IsEmpty)
     {
         InteractionLink.OnMessageCommit(clientAddress, message.ID);
     }
     Messages.Add(message);
 }
Exemple #4
0
        public static void Relay(Guid sender, Guid receiver, int channel, byte[] data, int generation)
        {
            InteractionLink link = Lookup(receiver);

            if (link != null)
            {
                link.RelayMessage(sender, receiver, channel, data, generation);
            }
        }
Exemple #5
0
 public static InteractionLink Establish(TcpClient client, Func <ShardID, Link> linkLookup)
 {
     try
     {
         InteractionLink rs = new InteractionLink(client, linkLookup);
         lock (registry)
         {
             registry.Add(rs);
         }
         return(rs);
     }
     catch
     { }
     return(null);
 }