Ejemplo n.º 1
0
            private void Handle(Packet pa)
            {
                HandshakePacket p = pa as HandshakePacket;

                if (p.Type == HandshakePacket.SessionType.Server)
                {
                    Slave sl = new Slave(p, ph);
                    Server.Servers.Add(sl);
                    Console.WriteLine("New Server: " + sl.ToString());
                    slave = sl;
                    ph.Stream.StreamDisposed += new EventHandler(Stream_StreamDisposed);
                    return;
                }
                string[] srvs  = new string[Server.Servers.Count];
                string[] addrs = new string[Server.Servers.Count];
                int[]    ports = new int[Server.Servers.Count];
                for (int i = 0; i < Server.Servers.Count; i++)
                {
                    srvs[i]  = Server.Servers[i].Name;
                    addrs[i] = Server.Servers[i].Address.ToString();
                    ports[i] = Server.Servers[i].Port;
                }
                Packet.Send(new ServerListPacket {
                    Servers = srvs, Locations = addrs, Ports = ports
                }, ph.Stream);
                ph.Stop();
                ClientDisconnected(this, EventArgs.Empty);
            }
Ejemplo n.º 2
0
 private void Handle(Packet pa)
 {
     HandshakePacket p = pa as HandshakePacket;
     if (p.Type == HandshakePacket.SessionType.Server)
     {
         Slave sl = new Slave(p, ph);
         Server.Servers.Add(sl);
         Console.WriteLine("New Server: " + sl.ToString());
         slave = sl;
         ph.Stream.StreamDisposed += new EventHandler(Stream_StreamDisposed);
         return;
     }
     string[] srvs = new string[Server.Servers.Count];
     string[] addrs = new string[Server.Servers.Count];
     int[] ports = new int[Server.Servers.Count];
     for (int i = 0; i < Server.Servers.Count; i++)
     {
         srvs[i] = Server.Servers[i].Name;
         addrs[i] = Server.Servers[i].Address.ToString();
         ports[i] = Server.Servers[i].Port;
     }
     Packet.Send(new ServerListPacket { Servers = srvs, Locations = addrs, Ports = ports }, ph.Stream);
     ph.Stop();
     ClientDisconnected(this, EventArgs.Empty);
 }