Exemple #1
0
 public GameSocketMessageHandlerInvoker this[GameSocket gameSocket]
 {
     get
     {
         lock (_invokers)
         {
             if (!_invokers.ContainsKey(gameSocket))
             {
                 return(null);
             }
             return(_invokers[gameSocket]);
         }
     }
     set
     {
         lock (_invokers)
         {
             if (!_invokers.ContainsKey(gameSocket))
             {
                 return;
             }
             _invokers.Add(gameSocket, value);
         }
     }
 }
Exemple #2
0
        private void IncomingConnectedAccepted(AsyncResultEventArgs <ServerChildTcpSocket> args)
        {
            if (args.Error != null)
            {
                // TODO: Die safely?
                CoreManager.ServerCore.StandardOut.Error("Game Socket Manager", "Incoming connection failed!!");

                // TODO: Pretty exception reporting
                Console.WriteLine();
                Console.WriteLine(args.Error.Message);
                Console.WriteLine(args.Error.StackTrace);

                _listeningSocket.AcceptAsync();
                return;
            }

            ServerChildTcpSocket internalSocket = args.Result;
            GameSocket           socket         = new GameSocket(internalSocket, Protocol);

            CancelReasonEventArgs connectionEventArgs = new CancelReasonEventArgs();

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection", EventPriority.Before, socket, connectionEventArgs);
            if (connectionEventArgs.Cancel)
            {
                socket.Disconnect("Connection rejected from " + internalSocket.RemoteEndPoint + "(" + connectionEventArgs.CancelReason + ")");
                return;
            }

            socket.Start();

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection", EventPriority.After, socket, connectionEventArgs);
            CoreManager.ServerCore.StandardOut.Notice("Game Socket Manager", "Incoming connection accepted: " + internalSocket.RemoteEndPoint);

            _listeningSocket.AcceptAsync();
        }
Exemple #3
0
        private void IncomingConnectedAccepted(AsyncResultEventArgs <ServerChildTcpSocket> args)
        {
            if (args.Error != null)
            {
                string dumpPath = CoreManager.ServerCore.DumpException(args.Error);
                CoreManager.ServerCore.ConsoleManager.Error("Game Socket Manager", "Incoming connection failed!!");
                CoreManager.ServerCore.ConsoleManager.Error("Game Socket Manager", "    An exception dump has been saved to " + dumpPath);
                _listeningSocket.AcceptAsync();
                return;
            }

            ServerChildTcpSocket internalSocket = args.Result;
            GameSocket           socket         = new GameSocket(internalSocket, this);

            GameSocketEventArgs eventArgs = new GameSocketEventArgs(socket);

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection:before", eventArgs);
            if (eventArgs.IsCancelled)
            {
                socket.Disconnect("Connection rejected from " + internalSocket.RemoteEndPoint + "(" + eventArgs.CancelReason + ")");
                return;
            }
            socket.Start();
            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection:after", eventArgs);
            CoreManager.ServerCore.ConsoleManager.Notice("Game Socket Manager", "Incoming connection accepted: " + internalSocket.RemoteEndPoint);

            _listeningSocket.AcceptAsync();
        }
 public GameSocketMessageHandlerInvoker this[GameSocket gameSocket]
 {
     get
     {
         lock (_invokers)
         {
             if (!_invokers.ContainsKey(gameSocket))
                 return null;
             return _invokers[gameSocket];
         }
     }
     set
     {
         lock (_invokers)
         {
             if (!_invokers.ContainsKey(gameSocket))
                 return;
             _invokers.Add(gameSocket, value);
         }
     }
 }
Exemple #5
0
 public void DeregisterGameSocket(GameSocket gameSocket)
 {
     _invokers.Remove(gameSocket);
 }
Exemple #6
0
 /// <summary>
 ///   Creates a minimal Habbo object.
 ///   This is not cached and is only used after the Habbo connects but before logging in.
 ///   Do not use this Habbo for custom features. Use a cached version.
 /// </summary>
 /// <param name = "socket">The Connection this Habbo is for.</param>
 /// <returns>A mostly non-function Habbo.</returns>
 public static Habbo GetPreLoginHabbo(GameSocket socket)
 {
     return new Habbo(socket);
 }
Exemple #7
0
 public GameSocketEventArgs(GameSocket socket, bool cancellable = true)
 {
     Socket = socket;
     Cancellable = cancellable;
 }
Exemple #8
0
        private void IncomingConnectedAccepted(AsyncResultEventArgs<ServerChildTcpSocket> args)
        {
            if(args.Error != null)
            {
                // TODO: Die safely?
                CoreManager.ServerCore.StandardOut.Error("Game Socket Manager", "Incoming connection failed!!");

                // TODO: Pretty exception reporting
                Console.WriteLine();
                Console.WriteLine(args.Error.Message);
                Console.WriteLine(args.Error.StackTrace);

                _listeningSocket.AcceptAsync();
                return;
            }

            ServerChildTcpSocket internalSocket = args.Result;
            GameSocket socket = new GameSocket(internalSocket, Protocol);

            CancelReasonEventArgs connectionEventArgs = new CancelReasonEventArgs();

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection", EventPriority.Before, socket, connectionEventArgs);
            if (connectionEventArgs.Cancel)
            {
                socket.Disconnect("Connection rejected from " + internalSocket.RemoteEndPoint + "(" + connectionEventArgs.CancelReason + ")");
                return;
            }

            socket.Start();

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection", EventPriority.After, socket, connectionEventArgs);
            CoreManager.ServerCore.StandardOut.Notice("Game Socket Manager", "Incoming connection accepted: " + internalSocket.RemoteEndPoint);

            _listeningSocket.AcceptAsync();
        }
 public void DeregisterGameSocket(GameSocket gameSocket)
 {
     _invokers.Remove(gameSocket);
 }
Exemple #10
0
 internal Habbo(GameSocket socket)
 {
     Socket = socket;
 }
Exemple #11
0
        private void IncomingConnectedAccepted(AsyncResultEventArgs<ServerChildTcpSocket> args)
        {
            if(args.Error != null)
            {
                string dumpPath = CoreManager.ServerCore.DumpException(args.Error);
                CoreManager.ServerCore.ConsoleManager.Error("Game Socket Manager", "Incoming connection failed!!");
                CoreManager.ServerCore.ConsoleManager.Error("Game Socket Manager", "    An exception dump has been saved to " + dumpPath);
                _listeningSocket.AcceptAsync();
                return;
            }

            ServerChildTcpSocket internalSocket = args.Result;
            GameSocket socket = new GameSocket(internalSocket, this);

            GameSocketEventArgs eventArgs = new GameSocketEventArgs(socket);

            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection:before", eventArgs);
            if (eventArgs.IsCancelled)
            {
                socket.Disconnect("Connection rejected from " + internalSocket.RemoteEndPoint + "(" + eventArgs.CancelReason + ")");
                return;
            }
            socket.Start();
            CoreManager.ServerCore.OfficalEventFirer.Fire("incoming_game_connection:after", eventArgs);
            CoreManager.ServerCore.ConsoleManager.Notice("Game Socket Manager", "Incoming connection accepted: " + internalSocket.RemoteEndPoint);

            _listeningSocket.AcceptAsync();
        }