Ejemplo n.º 1
0
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser(this);
 }
Ejemplo n.º 2
0
		private void connectionChanged(ConnectionInformation information, ConnectionState state)
		{
			if (state == ConnectionState.closed)
			{
				this.CloseConnection(information);
			}
		}
Ejemplo n.º 3
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.CLOSED)
     {
         CloseConnection(information);
     }
 }
Ejemplo n.º 4
0
		internal GameClient(uint ClientId, ConnectionInformation pConnection)
		{
			this.Id = ClientId;
			this.Connection = pConnection;
			this.CurrentRoomUserID = -1;
			this.packetParser = new GamePacketParser(this);
            this.Connection.SetClient(this);
		}
Ejemplo n.º 5
0
        public GameClient(int ClientId, ConnectionInformation pConnection)
        {
            this._id = ClientId;
            this._connection = pConnection;
            this._packetParser = new GamePacketParser(this);

            this.PingCount = 0;
        }
Ejemplo n.º 6
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         CloseConnection(information.getConnectionID());
         liveConnections.Remove(information.getConnectionID());
     }
 }
Ejemplo n.º 7
0
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     SetDoorPos = false;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser();
 }
Ejemplo n.º 8
0
 private void connection_connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     switch (state)
     {
         case ConnectionState.closed:
             disconnect();
             break;
     }
 }
Ejemplo n.º 9
0
        public ConnectionHandeler(ConnectionManager.ConnectionInformation connection)
        {
            this.connection     = connection;
            this.packetRegister = new PacketRegistery <ServerOpCode, ServerIncomingPacket>();

            packetRegister.registerPacket(ServerOpCode.Core_client_sends_version, ServerReceivedVersion);
            connection.sendData(new SharedPacketLib.DataPackets.ServerOutgoingPacket(ClientOpCode.Core_send_version));
            this.connection.connectionChanged += connection_connectionChanged;
            (this.connection.parser as GamePacketParser).packetArrival += ConnectionHandeler_packetArrival;
        }
Ejemplo n.º 10
0
        public ConnectionHandeler(ConnectionManager.ConnectionInformation connection)
        {
            this.connection = connection;
            this.packetRegister = new PacketRegistery<ServerOpCode, ServerIncomingPacket>();

            packetRegister.registerPacket(ServerOpCode.Core_client_sends_version, ServerReceivedVersion);
            connection.sendData(new SharedPacketLib.DataPackets.ServerOutgoingPacket(ClientOpCode.Core_send_version));
            this.connection.connectionChanged += connection_connectionChanged;
            (this.connection.parser as GamePacketParser).packetArrival += ConnectionHandeler_packetArrival;
        }
Ejemplo n.º 11
0
 private void CloseConnection(ConnectionInformation Connection)
 {
     try
     {
         Connection.Dispose();
         SilverwaveEnvironment.GetGame().GetClientManager().DisposeConnection((uint)Connection.getConnectionID());
     }
     catch (Exception e)
     {
         Logging.LogException(e.ToString());
     }
 }
Ejemplo n.º 12
0
		private void CloseConnection(ConnectionInformation Connection)
		{
			try
			{
				Connection.Dispose();
				CyberEnvironment.GetGame().GetClientManager().DisposeConnection(checked((uint)Connection.getConnectionID()));
			}
			catch (Exception ex)
			{
				Logging.LogException(ex.ToString());
			}
		}
Ejemplo n.º 13
0
 private void CloseConnection(ConnectionInformation Connection)
 {
     try
     {
         Connection.Dispose();
         PlusEnvironment.GetGame().GetClientManager().DisposeConnection(Convert.ToInt32( Connection.getConnectionID()));
     }
     catch (Exception e)
     {
         Logging.LogException(e.ToString());
     }
 }
Ejemplo n.º 14
0
		private void newConnectionRequest(IAsyncResult iAr)
		{
			checked
			{
				if (this.connectionListener != null && this.acceptConnections)
				{
					try
					{
						Socket socket = ((Socket)iAr.AsyncState).EndAccept(iAr);
						socket.NoDelay = this.disableNagleAlgorithm;
						string ip = socket.RemoteEndPoint.ToString().Split(new char[]
						{
							':'
						})[0];
						this.acceptedConnections++;
						ConnectionInformation connectionInformation = new ConnectionInformation(socket, this.acceptedConnections, this, this.parser.Clone() as IDataParser, ip);
						this.reportUserLogin(ip);
						connectionInformation.connectionChanged += new ConnectionInformation.ConnectionChange(this.c_connectionChanged);
						if (this.connectionEvent != null)
						{
							this.connectionEvent(connectionInformation);
						}
					}
					catch
					{
					}
					finally
					{
						this.connectionListener.BeginAccept(new AsyncCallback(this.newConnectionRequest), this.connectionListener);
					}
				}
			}
		}
Ejemplo n.º 15
0
 private void c_connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.CLOSED)
     {
         reportDisconnect(information);
     }
 }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
0
		public QueuedServerMessage(ConnectionInformation connection)
		{
			this.userConnection = connection;
			this.packet = new List<byte>();
		}
Ejemplo n.º 18
0
 public void CreateAndStartClient(int clientID, ConnectionInformation connection)
 {
     GameClient Client = new GameClient(clientID, connection);
     if (this._clients.TryAdd(Client.ConnectionID, Client))
         Client.StartConnection();
     else
         connection.Dispose();
 }
Ejemplo n.º 19
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     connection.connectionChanged += connectionChanged;
     PlusEnvironment.GetGame().GetClientManager().CreateAndStartClient(Convert.ToInt32(connection.getConnectionID()), connection);
 }
Ejemplo n.º 20
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     liveConnections.Add(connection.getConnectionID(), connection);
     connection.connectionChanged += connectionChanged;
     ButterflyEnvironment.GetGame().GetClientManager().CreateAndStartClient((uint)connection.getConnectionID(), connection);
 }
Ejemplo n.º 21
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());
 }
Ejemplo n.º 22
0
		public void SetConnection(ConnectionInformation con)
		{
			this.con = con;
			this.onNewPacket = null;
		}
Ejemplo n.º 23
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("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("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 (Exception ex) { 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);
                }
            }
        }
Ejemplo n.º 24
0
		internal void Dispose()
		{
			this.packet.Clear();
			this.userConnection = null;
		}
Ejemplo n.º 25
0
		internal void CreateAndStartClient(uint clientID, ConnectionInformation connection)
		{
			GameClient obj = new GameClient(clientID, connection);
            if (this.clients.Contains(clientID))
			{
				this.clients.Remove(clientID);
			}
			lock (this.clientsAddQueue.SyncRoot)
			{
				this.clientsAddQueue.Enqueue(obj);
			}
		}
Ejemplo n.º 26
0
 protected void CConnectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         this.ReportDisconnect(information);
     }
 }
Ejemplo n.º 27
0
		private void manager_connectionEvent(ConnectionInformation connection)
		{
			connection.connectionChanged += new ConnectionInformation.ConnectionChange(this.connectionChanged);
			CyberEnvironment.GetGame().GetClientManager().CreateAndStartClient(checked((uint)connection.getConnectionID()), connection);
		}
Ejemplo n.º 28
0
        static void man_connectionEvent(ConnectionManager.ConnectionInformation connection)
        {
            //TODO something with your new connection

            new ConnectionHandeler(connection);
        }
Ejemplo n.º 29
0
 public Client(NettyServer.Connection iAr)
 {
     try
     {
         _connection = iAr;
         Socket thisSocket = _connection.Socket;
         IP = thisSocket.RemoteEndPoint.ToString().Split(new char[]{':'})[0];
         this.acceptedConnections++;
         ConnectionInformation connectionInformation = new ConnectionInformation(thisSocket, this.acceptedConnections, this, this.parser, IP);
         this.reportUserLogin(IP);
         connectionInformation.connectionChanged += new ConnectionInformation.ConnectionChange(this.CConnectionChanged);
         if (connectionEvent != null)
         {
             connectionEvent(connectionInformation);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Ejemplo n.º 30
0
		private void c_connectionChanged(ConnectionInformation information, ConnectionState state)
		{
			if (state == ConnectionState.closed)
			{
				this.reportDisconnect(information);
			}
		}
Ejemplo n.º 31
0
		public void reportDisconnect(ConnectionInformation gameConnection)
		{
			gameConnection.connectionChanged -= new ConnectionInformation.ConnectionChange(this.c_connectionChanged);
			this.reportUserLogout(gameConnection.getIp());
		}
Ejemplo n.º 32
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);
            }
        }
 /// <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());
 }