예제 #1
0
파일: Program.cs 프로젝트: mkawick/Gateway
        private static void Main(string[] args)
        {
            Console.WriteLine("Gateway");
            // Console.WriteLine("  Press L to login (auto login is set).");
            // Console.WriteLine("  Press P to update player position.");
            Console.WriteLine("  Press esc to exit.\n\n");

            bool testAgainstRealLoginServer      = false;
            SocketWrapperSettings socketSettings = null;

            if (testAgainstRealLoginServer)
            {
                socketSettings = new SocketWrapperSettings("localhost", 11002);
            }
            LoginServerProxy loginServer = new LoginServerProxy(socketSettings);
            GatewayMain      gateway     = new GatewayMain(loginServer);

            gateway.SetMaxFPS(NetworkConstants.GatewayFPS);
            loginServer.StartService();
            gateway.StartService();

            ConsoleKey key;

            do
            {
                while (!Console.KeyAvailable)
                {
                    Thread.Sleep(20);
                }
                key = Console.ReadKey(true).Key;
            } while (key != ConsoleKey.Escape);
            loginServer.Cleanup();
            gateway.Cleanup();
        }
예제 #2
0
        public ServerNetworking(SocketWrapperSettings profileServerSettings, SocketWrapperSettings _gatewayServerSettings, int appId)
        {
            this.OnExceptionFromThread += GameServer_OnExceptionFromThread;

            SetMaxFPS(NetworkConstants.GameServerFPS);

            connectedClients         = new Dictionary <int, ConnectedClient>();
            newlyConnectedClients    = new List <ConnectedClient>();
            newlyDisconnectedClients = new List <ConnectedClient>();

            packetDispatcher = new PacketDispatcher();

            profileServer = new ProfileServerProxy(profileServerSettings);
            profileServer.OnReceivePacket += ProfileServer_OnReceivePacket;
            profileServer.Connect();

            applicationId = appId;

            // _gatewayServerSettings.ipAddress = "localhost";
            gatewayServerSettings = _gatewayServerSettings;
            ConnectToGateway();

            startTime      = Stopwatch.StartNew();
            frameTickTimer = Stopwatch.StartNew();

            UnboundPacketHandler  = new UnboundToGatewayPacketHandler(this);
            BoundPacketHandler    = new BoundToGatewayPacketHandler(this);
            CurrentPacketHandling = UnboundPacketHandler;
        }
예제 #3
0
        public ProfileServerProxy(SocketWrapperSettings socketSettings)
        {
            incomingPackets = new Queue <BasePacket>();
            outgoingPackets = new Queue <BasePacket>();

            if (socketSettings != null)
            {
                socket = new SocketWrapper(socketSettings);
                socket.OnPacketsReceived += ProfileServer_OnPacketsReceived;
            }
        }
예제 #4
0
        //private float estimatedServerFrameTime = 0f;

        public ClientNetworking(SocketWrapperSettings settings, int appId)
        {
            FrameID = NetworkConstants.BeforeStartOfGameFrameId;

            packetDispatcher = new PacketDispatcher();
            cpcs             = new ClientPlayerConnectionState(new SocketWrapper(settings), appId);

            // Forward events from the CPCS to IClientNetworking
            cpcs.OnConnect       += () => { OnConnect?.Invoke(); };
            cpcs.OnDisconnect    += (retry) => { OnDisconnect?.Invoke(retry); };
            cpcs.OnLoginResponse += (response) => { OnLoginResponse?.Invoke(response); };

            // We want to know when the server tells us it's frameid, so we can keep in sync
            packetDispatcher.AddListener <ServerTick>(OnServerTickPacket);
        }
예제 #5
0
        //------------------------------------------------------------------

        public LoginServerProxy(SocketWrapperSettings loginServerToConnectTo)
        {
            newConnections   = new List <PlayerConnectionState>();
            limboConnections = new List <PlayerConnectionState>();
            loggedInPlayers  = new List <PlayerConnectionState>();
            invalidPlayers   = new List <PlayerConnectionState>();

            unprocessedLoginServerResponses = new List <BasePacket>();

            isConnectedToRealLogin = loginServerToConnectTo != null;
            if (isConnectedToRealLogin == true)
            {
                loginServerSocket = new SocketWrapper(loginServerToConnectTo);
                loginServerSocket.OnPacketsReceived += LoginServerSocket_OnPacketsReceived;
                loginServerSocket.Connect();
            }
            configuredSleep = NetworkConstants.LoginProxyFPS;
        }
예제 #6
0
        private static void Main(string[] args)
        {
            Console.WriteLine("listening server");
            // Console.WriteLine("  Press L to login (auto login is set).");
            // Console.WriteLine("  Press P to update player position.");
            Console.WriteLine("  Press esc to exit.\n\n");

            bool testAgainstRealLoginServer      = false;
            SocketWrapperSettings socketSettings = null;

            if (testAgainstRealLoginServer)
            {
                socketSettings = new SocketWrapperSettings("localhost", 11002);
            }
            IntrepidSerialize.Init();
            LoginServerProxy loginServer = new LoginServerProxy(socketSettings);
            ServerController controller  = new ServerController(loginServer);

            ServerMockConnectionState mock = new ServerMockConnectionState(controller);

            controller.SetMaxFPS(NetworkConstants.GatewayFPS);
            controller.StartService();

            loginServer.StartService();
            mock.ConnectMock();

            Thread.Sleep(1000);// allow systems to init
            controller.NewServerConnection(mock);
            ConsoleKey key;

            do
            {
                while (!Console.KeyAvailable)
                {
                    Thread.Sleep(20);
                }
                key = Console.ReadKey(true).Key;
            } while (key != ConsoleKey.Escape);
            loginServer.Cleanup();
            controller.Cleanup();
        }