Exemplo n.º 1
0
        protected BaseServer()
        {
            Log = Logs.Create(LogCategory.Network, GetType().Name);

            RecvClientState       = new TrafficCounter();
            RecvHandshakeRequest  = new TrafficCounter();
            RecvPacketRelay       = new TrafficCounter();
            SentTraffic           = new TrafficCounter();
            RecvDeltaChannelState = new TrafficCounter();

            var rand = new Random();

            while (_sessionId == 0)
            {
                _sessionId = unchecked ((uint)rand.Next());
            }

            _clients = new BroadcastingClientCollection <TPeer>(this);
            _relay   = new ServerRelay <TPeer>(this, _clients);

            serverAdmin                        = new ServerAdmin <TServer, TClient, TPeer>((TServer)this);
            _clients.OnClientJoined           += serverAdmin.InvokeOnClientJoined;
            _clients.OnClientLeft             += serverAdmin.InvokeOnClientLeft;
            _clients.OnClientEnteredRoomEvent += serverAdmin.InvokeOnClientEnteredRoom;
            _clients.OnClientExitedRoomEvent  += serverAdmin.InvokeOnClientExitedRoom;
            _relay.OnRelayingPacket           += serverAdmin.InvokeOnRelayingPacket;

            Log.Info("Created server with SessionId:{0}", _sessionId);
        }
Exemplo n.º 2
0
        protected BaseServer()
        {
            Log = Logs.Create(LogCategory.Network, GetType().Name);

            RecvClientState       = new TrafficCounter();
            RecvHandshakeRequest  = new TrafficCounter();
            RecvPacketRelay       = new TrafficCounter();
            SentTraffic           = new TrafficCounter();
            RecvDeltaChannelState = new TrafficCounter();

            var rand = new Random();

            while (_sessionId == 0)
            {
                _sessionId = unchecked ((uint)rand.Next());
            }

            _clients = new BroadcastingClientCollection <TPeer>(this);
            _relay   = new ServerRelay <TPeer>(this, _clients);

            // Before 6.4.3 this message was:
            //   `Constructing host. SessionId:{0}`
            // Changed for clarity.
            Log.Info("Created server with SessionId:{0}", _sessionId);
        }
Exemplo n.º 3
0
 private void InitNetwork(int MaxConnections, int Port)
 {
     server = new ServerRelay(MaxConnections, Port);
     InitMessage();
     InitEvent();
 }