예제 #1
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         CloseConnection(information.getConnectionID());
         liveConnections.Remove(information.getConnectionID());
     }
 }
예제 #2
0
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     SetDoorPos = false;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser();
 }
예제 #3
0
        internal void Stop()
        {
            if (GetMessageHandler() != null)
                MessageHandler.Destroy();

            if (GetHabbo() != null)
                Habbo.OnDisconnect();
            CurrentRoomUserID = -1;

            this.MessageHandler = null;
            this.Habbo = null;
            this.Connection = null;
        }
예제 #4
0
 internal void Dispose()
 {
     packet.Clear();
     userConnection = null;
 }
예제 #5
0
 public QueuedServerMessage(ConnectionInformation connection)
 {
     this.userConnection = connection;
     this.packet = new List<byte>(4096);
 }
예제 #6
0
        /// <summary>
        /// Handels a new incoming data request from some computer from arround the world
        /// </summary>
        /// <param name="iAr">the IAsyncResult of the connection</param>
        private void newConnectionRequest(IAsyncResult iAr)
        {
            if (this.connectionListener != null)
            {
                if (acceptConnections)
                {
                    try
                    {
                        Socket replyFromComputer = ((Socket)iAr.AsyncState).EndAccept(iAr);
                        replyFromComputer.NoDelay = this.disableNagleAlgorithm;
                        Out.writeLine("[CONN MANAGER] >> New connection from [" + replyFromComputer.RemoteEndPoint.ToString().Split(':')[0] + "].", Out.logFlags.StandardLogLevel);

                        //if (activeConnections.Count < maximumConnections)
                        {

                            string Ip = replyFromComputer.RemoteEndPoint.ToString().Split(':')[0];
                            //if (getAmountOfConnectionFromIp(Ip) < maxIpConnectionCount)
                            {
                                acceptedConnections++;
                                Out.writeLine("[CONN MANAGER] >> Accepted connection [" + acceptedConnections + "] from  [" + replyFromComputer.RemoteEndPoint.ToString().Split(':')[0] + "].", Out.logFlags.BelowStandardlogLevel);
                                ConnectionInformation c = new ConnectionInformation(replyFromComputer, acceptedConnections, this, parser.Clone() as IDataParser, Ip);
                                reportUserLogin(Ip);
                                c.connectionChanged += c_connectionChanged;
                                //activeConnections.Add(acceptedConnections, c);
                                if (connectionEvent != null)
                                    connectionEvent(c);

                            }
                            //else
                            //    Out.writeLine("Connection denied from [" + replyFromComputer.RemoteEndPoint.ToString().Split(':')[0] + "]. The user has too many connections", Out.logFlags.StandardLogLevel);
                        }
                        //else
                        //    Out.writeLine("Maximum amount of connections reached " + maximumConnections, Out.logFlags.ImportantLogLevel);
                    }
                    catch
                    {
                        //Out.writeError(ex.Message); }

                    }
                    finally
                    {
                        connectionListener.BeginAccept(new AsyncCallback(newConnectionRequest), connectionListener);
                    }
                }
                else
                {
                    Out.writeLine("Connection denied, server is not currently accepting connections!", Out.logFlags.StandardLogLevel);
                }
            }
        }
예제 #7
0
 void c_connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         reportDisconnect(information);
     }
 }
예제 #8
0
 /// <summary>
 /// Reports a gameconnection as disconnected
 /// </summary>
 /// <param name="gameConnection">The connection which is logging out</param>
 public void reportDisconnect(ConnectionInformation gameConnection)
 {
     gameConnection.connectionChanged -= c_connectionChanged;
     reportUserLogout(gameConnection.getIp());
     //activeConnections.Remove(gameConnection.getConnectionID());
 }
예제 #9
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     liveConnections.Add(connection.getConnectionID(), connection);
     connection.connectionChanged += connectionChanged;
     PiciEnvironment.GetGame().GetClientManager().CreateAndStartClient((uint)connection.getConnectionID(), connection);
 }
예제 #10
0
        internal void CreateAndStartClient(uint clientID, ConnectionInformation connection)
        {
            GameClient client = new GameClient(clientID, connection);
            if (clients.ContainsKey(clientID))
                clients.Remove(clientID);

            lock (clientsAddQueue.SyncRoot)
            {
                clientsAddQueue.Enqueue(client);
            }
        }
예제 #11
0
 public void SetConnection(ConnectionInformation con)
 {
     this.con = con;
     this.onNewPacket = null;
 }