Beispiel #1
0
        private ServiceConnection AttatchHandlersToService(ServiceConnection service)
        {
            service.FoundNode += Service_FoundNode;
            service.MessageReceived += Service_MessageReceived;
            service.AnnounceServers += Service_AnnounceServers;
            service.AnnounceNodes += Service_AnnounceNodes;
            service.FoundServer += Service_FoundServer;
            service.IsRouter += Service_IsRouter;
            service.Disconnected += Service_Disconnected;

            FoundServer(this, new FoundServerEventArgs { Ip = service.Ip, Accessable = service.Accessable });

            AnnounceAllNodesToServer(service);
            AnnounceAllServersTo(service);

            if (Server != null && Type == ServiceType.Full)
                service.Send("router;");
            else
                service.Send("client;");

            return service;
        }
Beispiel #2
0
 private void AnnounceOneServerToEveryone(ServiceConnection service)
 {
     foreach (ServiceConnection connection in Connections.Where(i => i.Available))
     {
         if (service.Accessable && service.Ip != connection.Ip)
             connection.Send("server:" + service.Ip);
     }
 }
Beispiel #3
0
 private void AnnounceOneServerTo(ServiceConnection to, ServiceConnection service)
 {
     if (service.Accessable && to.Ip != service.Ip)
         to.Send("server:" + service.Ip);
 }
Beispiel #4
0
 private void AnnounceOneNodeToServer(Node node, ServiceConnection service)
 {
     service.Send(node.ToString());
 }
Beispiel #5
0
 private void AnnounceAllServersTo(ServiceConnection to)
 {
     foreach (ServiceConnection connection in Connections.Where(i => i != to).Where(i => i.Accessable))
     {
         if (to.Ip != connection.Ip)
             to.Send("server:" + connection.Ip);
     }
 }
Beispiel #6
0
 private void AnnounceAllNodesToServer(ServiceConnection service)
 {
     foreach (Node node in Nodes)
         service.Send(node.ToString());
 }