/// <summary>
        /// When a new connection is established, we the parent class are responsible
        /// for handling the processing
        /// </summary>
        /// <param name="Stream">A GamespyTcpStream object that wraps the I/O AsyncEventArgs and socket</param>
        protected override void ProcessAccept(TCPStream stream)
        {
            // Get our connection id
            long       ConID = Interlocked.Increment(ref ConnectionCounter);
            ChatClient client;

            try
            {
                // Convert the TcpClient to a MasterClient
                client = new ChatClient(stream, ConID);
                Clients.TryAdd(ConID, client);

                // Start receiving data
                stream.BeginReceive();
            }
            catch
            {
                // Remove pending connection
                Clients.TryRemove(ConID, out client);
            }
        }
Exemple #2
0
        /// <summary>
        /// When a new connection is established, we the parent class are responsible
        /// for handling the processing
        /// </summary>
        /// <param name="Stream">A GamespyTcpStream object that wraps the I/O AsyncEventArgs and socket</param>
        protected override void ProcessAccept(TCPStream stream)
        {
            // Get our connection id
            long         conid = Interlocked.Increment(ref ConnectionCounter);
            GStatsClient client;

            try
            {
                // Convert the TcpClient to a MasterClient
                client = new GStatsClient(stream, conid);
                Clients.TryAdd(conid, client);
                client.SendServerChallenge();
                // Start receiving data
                stream.BeginReceive();
            }
            catch
            {
                // Remove pending connection
                Clients.TryRemove(conid, out client);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ReadArgs">The Tcp Client connection</param>
        public GPCMClient(TCPStream ConnectionStream, long ConnectionId, DatabaseDriver databaseDriver)
        {
            // Set default variable values
            PlayerNick         = "Connecting...";
            PlayerStatusString = "Offline";
            PlayerLocation     = "";
            PlayerId           = 0;
            RemoteEndPoint     = (IPEndPoint)ConnectionStream.RemoteEndPoint;
            Disposed           = false;
            LoginStatus        = LoginStatus.Connected;
            PlayerStatus       = PlayerStatus.Offline;

            // Set the connection ID
            this.ConnectionId   = ConnectionId;
            this.databaseDriver = databaseDriver;

            // Create our Client Stream
            Stream = ConnectionStream;
            Stream.OnDisconnect += OnStreamDisconnects;
            Stream.DataReceived += OnDataReceived;
            Stream.BeginReceive();
        }
        /// <summary>
        /// Accepts a TcpClient, and begin the serverlist fetching process for the client.
        /// This method is executed when the user updates his server browser ingame
        /// </summary>
        protected override void ProcessAccept(TCPStream Stream)
        {
            // Get our connection id
            long     ConID = Interlocked.Increment(ref ConnectionCounter);
            SBClient client;

            // End the operation and display the received data on
            // the console.
            try
            {
                // Convert the TcpClient to a MasterClient
                client = new SBClient(Stream, ConID);
                Clients.TryAdd(client.ConnectionID, client);

                // Start receiving data
                Stream.BeginReceive();
            }
            catch (ObjectDisposedException) // Ignore
            {
                // Remove client
                Clients.TryRemove(ConID, out client);
            }
            catch (IOException) // Connection closed before a TcpClientStream could be made
            {
                // Remove client
                Clients.TryRemove(ConID, out client);
            }
            catch (Exception e)
            {
                // Remove client
                Clients.TryRemove(ConID, out client);

                // Report error

                LogWriter.Log.Write(LogLevel.Error, "[SB] : An Error occured at : {0}", e.ToString());

                //ExceptionHandler.GenerateExceptionLog(e);
            }
        }
Exemple #5
0
 /// <summary>
 /// This function is fired when a client is being accepted
 /// </summary>
 /// <param name="Stream">The stream of the client to be accepted</param>
 protected override void ProcessAccept(TCPStream Stream)
 {
     Stream.DataReceived += ProcessDataReceived;
     Stream.OnDisconnect += (stream) => stream.Dispose();
     Stream.BeginReceive();
 }