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; }
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; }
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 }