TimeSpan whiteListTimeOut = new TimeSpan(6,0,0); // 6 hours for the whitelist to time out // CONSTRUCTOR public Server(NetworkingInfo netinfo) { networkingInfo = netinfo; if(networkingInfo.port == -1) networkingInfo.port = NetworkingInfo.defaultPort; if(networkingInfo.address == "") networkingInfo.address = NetworkingInfo.defaultAddress; // TODO: Add some kind of DNS pre check for IP? connectedPlayers = new List<ServerPlayer>(); whiteList = new Dictionary<string, DateTime>(); pendingConnections = new Queue<NetworkConnection>(); config = new ConnectionConfig(); Channels.priority = config.AddChannel(QosType.AllCostDelivery); Channels.reliable = config.AddChannel(QosType.ReliableSequenced); Channels.unreliable = config.AddChannel(QosType.UnreliableSequenced); Channels.fragmented = config.AddChannel(QosType.ReliableFragmented); Channels.update = config.AddChannel(QosType.StateUpdate); hostconfig = new HostTopology(config, maxConcurrentConnectedUsers); NetworkServer.Configure(hostconfig); NetworkServer.Listen(networkingInfo.port); NetworkServer.RegisterHandler(MsgType.Connect, OnClientConnected); common.printConsole (tag, "Setup complete", true); networkingInfo.address = NetworkingCommon.localServer; }
void Start() { common = RPC.NetworkingCommon.Instance; networkingInfo = GameController.Instance.networkingInfo; if (networkingInfo.port == -1) { networkingInfo.port = RPC.NetworkingInfo.defaultPort; } if (networkingInfo.address == "") { networkingInfo.address = RPC.NetworkingInfo.defaultAddress; } playerLog = GetComponent <PlayerLog>(); common.RegisterOnConsole(playerLog.AddEvent); if (networkingInfo.isServer) { server = new RPC.Server(networkingInfo); server.RegisterOnClient(ClientAvailable); } client = new RPC.Client(networkingInfo); client.RegisterClientShutdown(ShutdownClient); }
// CONSTRUCTOR public Server(NetworkingInfo netinfo) { networkingInfo = netinfo; if(networkingInfo.port == -1) networkingInfo.port = NetworkingInfo.defaultPort; if(networkingInfo.address == "") networkingInfo.address = NetworkingInfo.defaultAddress; // TODO: Add some kind of DNS pre check for IP? connectedPlayers = new List<ServerPlayer>(); whiteList = new Dictionary<string, DateTime>(); pendingConnections = new Queue<NetworkConnection>(); config = new ConnectionConfig(); Channels.priority = config.AddChannel(QosType.AllCostDelivery); Channels.reliable = config.AddChannel(QosType.ReliableSequenced); Channels.unreliable = config.AddChannel(QosType.UnreliableSequenced); Channels.fragmented = config.AddChannel(QosType.ReliableFragmented); Channels.update = config.AddChannel(QosType.StateUpdate); hostconfig = new HostTopology(config, maxConcurrentConnectedUsers); NetworkServer.Configure(hostconfig); NetworkServer.Listen(networkingInfo.port); NetworkServer.RegisterHandler(MsgType.Connect, OnClientConnected); common.printConsole (tag, "Setup complete", true); networkingInfo.address = NetworkingCommon.localServer; }
// CONSTRUCTOR public Client(NetworkingInfo netinfo) { networkingInfo = netinfo; if (networkingInfo.port == -1) { networkingInfo.port = NetworkingInfo.defaultPort; } if (networkingInfo.address == "") { networkingInfo.address = NetworkingInfo.defaultAddress; } // TODO: Add some kind of DNS pre check for IP? connectedPlayers = new List <Player>(); config = new ConnectionConfig(); Channels.priority = config.AddChannel(QosType.AllCostDelivery); Channels.reliable = config.AddChannel(QosType.ReliableSequenced); Channels.unreliable = config.AddChannel(QosType.UnreliableSequenced); Channels.fragmented = config.AddChannel(QosType.ReliableFragmented); Channels.update = config.AddChannel(QosType.StateUpdate); hostconfig = new HostTopology(config, maxConcurrentConnectedUsers); if (networkingInfo.isServer) { myClient = ClientScene.ConnectLocalServer(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); } else { myClient = new NetworkClient(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Error, ConnectionError); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); common.printConsole(tag, "Setup complete", true); myClient.Connect(networkingInfo.address, networkingInfo.port); common.printConsole(tag, "Connecting to " + networkingInfo.address + ":" + networkingInfo.port, true); } }
void Start () { common = RPC.NetworkingCommon.Instance; networkingInfo = GameController.Instance.networkingInfo; if(networkingInfo.port == -1) networkingInfo.port = RPC.NetworkingInfo.defaultPort; if(networkingInfo.address == "") networkingInfo.address = RPC.NetworkingInfo.defaultAddress; playerLog = GetComponent<PlayerLog>(); common.RegisterOnConsole(playerLog.AddEvent); if(networkingInfo.isServer) { server = new RPC.Server(networkingInfo); server.RegisterOnClient(ClientAvailable); } client = new RPC.Client(networkingInfo); client.RegisterClientShutdown(ShutdownClient); }
// CONSTRUCTOR public Client(NetworkingInfo netinfo) { networkingInfo = netinfo; if(networkingInfo.port == -1) networkingInfo.port = NetworkingInfo.defaultPort; if(networkingInfo.address == "") networkingInfo.address = NetworkingInfo.defaultAddress; // TODO: Add some kind of DNS pre check for IP? connectedPlayers = new List<Player>(); config = new ConnectionConfig(); Channels.priority = config.AddChannel(QosType.AllCostDelivery); Channels.reliable = config.AddChannel(QosType.ReliableSequenced); Channels.unreliable = config.AddChannel(QosType.UnreliableSequenced); Channels.fragmented = config.AddChannel(QosType.ReliableFragmented); Channels.update = config.AddChannel(QosType.StateUpdate); hostconfig = new HostTopology(config, maxConcurrentConnectedUsers); if(networkingInfo.isServer) { myClient = ClientScene.ConnectLocalServer(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); } else { myClient = new NetworkClient(); myClient.Configure(hostconfig); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MsgType.Error, ConnectionError); myClient.RegisterHandler(MsgType.Disconnect, ConnectionFailed); registerAllCallbacks(myClient, cbClientHandler); common.printConsole (tag, "Setup complete", true); myClient.Connect(networkingInfo.address, networkingInfo.port); common.printConsole (tag, "Connecting to " + networkingInfo.address + ":" + networkingInfo.port, true); } }