示例#1
0
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser(this);
 }
		private void connectionChanged(ConnectionInformation information, ConnectionState state)
		{
			if (state == ConnectionState.closed)
			{
				this.CloseConnection(information);
			}
		}
示例#3
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.CLOSED)
     {
         CloseConnection(information);
     }
 }
示例#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);
		}
示例#5
0
文件: GameClient.cs 项目: BjkGkh/Boon
        public GameClient(int ClientId, ConnectionInformation pConnection)
        {
            this._id = ClientId;
            this._connection = pConnection;
            this._packetParser = new GamePacketParser(this);

            this.PingCount = 0;
        }
示例#6
0
 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         CloseConnection(information.getConnectionID());
         liveConnections.Remove(information.getConnectionID());
     }
 }
示例#7
0
文件: GameClient.cs 项目: habb0/Bfly
 internal GameClient(uint ClientId, ConnectionInformation pConnection)
 {
     Id = ClientId;
     Connection = pConnection;
     SetDoorPos = false;
     CurrentRoomUserID = -1;
     packetParser = new GamePacketParser();
 }
示例#8
0
 private void connection_connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     switch (state)
     {
         case ConnectionState.closed:
             disconnect();
             break;
     }
 }
示例#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;
        }
示例#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;
        }
示例#11
0
 private void CloseConnection(ConnectionInformation Connection)
 {
     try
     {
         Connection.Dispose();
         SilverwaveEnvironment.GetGame().GetClientManager().DisposeConnection((uint)Connection.getConnectionID());
     }
     catch (Exception e)
     {
         Logging.LogException(e.ToString());
     }
 }
示例#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());
			}
		}
示例#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());
     }
 }
示例#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);
					}
				}
			}
		}
示例#15
0
 private void c_connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.CLOSED)
     {
         reportDisconnect(information);
     }
 }
示例#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;
        }
示例#17
0
		public QueuedServerMessage(ConnectionInformation connection)
		{
			this.userConnection = connection;
			this.packet = new List<byte>();
		}
示例#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();
 }
示例#19
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     connection.connectionChanged += connectionChanged;
     PlusEnvironment.GetGame().GetClientManager().CreateAndStartClient(Convert.ToInt32(connection.getConnectionID()), connection);
 }
示例#20
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     liveConnections.Add(connection.getConnectionID(), connection);
     connection.connectionChanged += connectionChanged;
     ButterflyEnvironment.GetGame().GetClientManager().CreateAndStartClient((uint)connection.getConnectionID(), connection);
 }
示例#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());
 }
示例#22
0
		public void SetConnection(ConnectionInformation con)
		{
			this.con = con;
			this.onNewPacket = null;
		}
示例#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);
                }
            }
        }
示例#24
0
		internal void Dispose()
		{
			this.packet.Clear();
			this.userConnection = null;
		}
示例#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);
			}
		}
示例#26
0
 protected void CConnectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.closed)
     {
         this.ReportDisconnect(information);
     }
 }
示例#27
0
		private void manager_connectionEvent(ConnectionInformation connection)
		{
			connection.connectionChanged += new ConnectionInformation.ConnectionChange(this.connectionChanged);
			CyberEnvironment.GetGame().GetClientManager().CreateAndStartClient(checked((uint)connection.getConnectionID()), connection);
		}
示例#28
0
        static void man_connectionEvent(ConnectionManager.ConnectionInformation connection)
        {
            //TODO something with your new connection

            new ConnectionHandeler(connection);
        }
示例#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);
     }
 }
示例#30
0
		private void c_connectionChanged(ConnectionInformation information, ConnectionState state)
		{
			if (state == ConnectionState.closed)
			{
				this.reportDisconnect(information);
			}
		}
示例#31
0
		public void reportDisconnect(ConnectionInformation gameConnection)
		{
			gameConnection.connectionChanged -= new ConnectionInformation.ConnectionChange(this.c_connectionChanged);
			this.reportUserLogout(gameConnection.getIp());
		}
示例#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());
 }