Ejemplo n.º 1
0
        public static void Switch(GPSPClient client, Dictionary <string, string> recv)
        {
            string command = recv.Keys.First();

            try
            {
                switch (command)
                {
                case "search":
                    SearchHandler.SearchUsers(client, recv);
                    break;

                case "valid":
                    ValidHandler.IsEmailValid(client, recv);
                    break;

                case "nicks":
                    NickHandler.SearchNicks(client, recv);
                    break;

                case "pmatch":
                    PmatchHandler.PlayerMatch(client, recv);
                    break;

                case "check":
                    CheckHandler.CheckProfileid(client, recv);
                    break;

                case "newuser":
                    NewUserHandler.NewUser(client, recv);
                    break;

                case "searchunique":
                    SearchUniqueHandler.SearchProfileWithUniquenick(client, recv);
                    break;

                case "others":
                    OthersHandler.SearchOtherBuddy(client, recv);
                    break;

                case "otherslist":
                    OthersListHandler.SearchOtherBuddyList(client, recv);
                    break;

                case "uniquesearch":
                    UniqueSearchHandler.SuggestUniqueNickname(client, recv);
                    break;

                default:
                    LogWriter.Log.Write("[GPSP] received unknown data " + command, LogLevel.Debug);
                    GameSpyUtils.PrintReceivedGPDictToLogger(command, recv);
                    GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "An invalid request was sended.");
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Callback for when a connection had disconnected
 /// </summary>
 /// <param name="sender">The client object whom is disconnecting</param>
 private void ClientDisconnected(GPSPClient client)
 {
     // Release this stream's AsyncEventArgs to the object pool
     Release(client.Stream);
     if (Clients.TryRemove(client.ConnectionID, out client) && !client.Disposed)
     {
         client.Dispose();
     }
 }
Ejemplo n.º 3
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);
            GPSPClient client;

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

                // Start receiving data
                stream.BeginReceive();
            }
            catch
            {
                // Remove pending connection
                Clients.TryRemove(ConID, out client);
            }
        }