예제 #1
0
 public NetworkLobby(long guid, int maxClients)
 {
     GUID = guid;
     Clients = new List<LobbyPlayer>(maxClients);
     portting:
     int port = new Random().Next(4000, IPEndPoint.MaxPort);
     if(TakenPorts.Contains(port))
         goto portting;
     _layer = new NetworkLayer(GUID.ToString(), NetworkLayerStatus.Online, new IPEndPoint(IPAddress.IPv6Any, port));
     Port = port;
     TakenPorts.Add(port);
     _layer.AddHandler(authorize_Req);
     MaxClients = maxClients;
 }
예제 #2
0
        public NetworkPlayer(string username, long guid, IPEndPoint _server)
        {
            GUID = guid;
            server = _server;
            Username = username;
            PlayerConnection = new NetworkLayer("PlayerConnection [" + username + "]", NetworkLayerStatus.Online, new IPEndPoint(IPAddress.IPv6Any, 22869));
            PlayerConnection.AddHandler(udpPacket_Received);

            MemoryStream memsr = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(memsr);
            writer.Write((short)NetworkPacketHeader.MasterAuthorize);
            writer.Write(Username);
            writer.Flush();

            byte[] data = memsr.ToArray();
            //writer.Close();

            PlayerConnection.SendPacket(data, server, true);  // Ask the master server if we're allowed to connect.
            Status = NetworkPlayerStatus.Awaiting;
        }
예제 #3
0
 public void InitializeServer()
 {
     _masterLayer = new NetworkLayer("Master", NetworkLayerStatus.Online, new IPEndPoint(IPAddress.IPv6Any, _port));
     Log.Debug("Networking Master Server is now online.");
     new Thread(checkQueue).Start();
     RegisterHandler(connect_Request);  // Master Authorization
 }