public Statistics(MessageBuffer buffer,RelaySessionClient client, RelaySessionServer server)
 {
     if (instance != null) throw new Exception("Statistics already exist");
     this.buffer = buffer;
     this.client = client;
     this.server = server;
     cacheSize = new List<long>();
     stateCacheSize = new List<long>();
     channels = new Dictionary<int, int>();
     channelSizes = new Dictionary<int, List<int>>();
     Statistics.instance = this;
 }
Exemple #2
0
        public void startHost(int cp, string host, int sp)
        {
            this.clientHost = host;
            this.clientPort = cp;
            this.serverPort = sp;

            hostID = Protocol.TUniqueID.generate();
            worldID = Protocol.TUniqueID.generate();
            buffer = new MessageBuffer(this);
            sessionClient = new RelaySessionClient("SessionClient1", host, clientPort + 1, this, buffer);
            infoClient = new RelayInfoClient("InfoClient1", clientHost, clientPort, this);
            sessionServer = new RelaySessionServer("SessionServer1", serverPort + 1,this, buffer);
            infoServer = new RelayInfoServer("InfoServer1", serverPort, this);
            Statistics stats = new Statistics(buffer, sessionClient, sessionServer);
            sessionClient.setServer(sessionServer);
            infoClient.setServer(infoServer);
            if (infoClient.connect() && sessionClient.connect())
            {
                Log.notify("Clients connected", this);
                if(infoServer.connect() && sessionServer.connect())
                {
                    Log.notify("Server started on port "+serverPort, this);
                    Console.ReadLine();

                    disconnect();
                }
                else
                {
                    Log.error("Failed to start server", this);
                }
            }
            else
            {
                Log.error("Failed to connect gameclient", this);
            }
        }