コード例 #1
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         CloseConnection(information.getConnectionID());
         liveConnections.Remove(information.getConnectionID());
     }
 }
コード例 #2
0
ファイル: GameClient.cs プロジェクト: habb0/PiciEmulator
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     SetDoorPos = false;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser();
 }
コード例 #3
0
ファイル: GameClient.cs プロジェクト: habb0/PiciEmulator
        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;
 }