Esempio n. 1
0
        private static async Task ConnectToMasterRouterAsync(IPAddress address, int port)
        {
            TcpClient routerClient = null;

            LogonServices.InteropConnectionManager.Connect(tcpClient => routerClient = tcpClient);

            var routingClient = new AERoutingClient(routerClient, LogonServices.InteropPacketHandler,
                                                    LogonServices.IncomingRoutingMiddlewareHandler,
                                                    LogonServices.OutgoingRoutingMiddlewareHandler,
                                                    LogonServices.ObjectRepository);

            var chbp = new ClientHandshakeBeginPacket
            {
                Protocol  = Constants.LatestAEProtocolVersion,
                Password  = "******",
                Component = new RoutingComponent
                {
                    Type = ComponentType.UniversalAuthServer
                }
            };

            await routingClient.SendDataAsync(chbp.FinalizePacket());

            await routingClient.ListenForDataTask();

            LogonServices.ObjectRepository.RemoveObject(routingClient.ClientGuid);
        }
Esempio n. 2
0
        private static async void AcceptAEClientAsync(TcpClient rawClient)
        {
            Console.WriteLine("Accepting AEClient");
            var client = new AERoutingClient(rawClient, MasterRouterServices.PacketHandler,
                                             MasterRouterServices.IncomingMiddlewareHandler,
                                             MasterRouterServices.OutgoingMiddlewareHandler,
                                             MasterRouterServices.ObjectRepository);

            try
            {
                await client.ListenForDataTask();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Unhandled exception in {nameof(AcceptAEClientAsync)}: {ex}");
            }
            finally
            {
                if (client.ClientGuid != Guid.Empty)
                {
                    MasterRouterServices.ObjectRepository.RemoveObject(client.ClientGuid);
                    MasterRouterServices.RemoteClients.RemoveClient(client.ClientGuid);
                }
            }

            client.Disconnect();
        }
Esempio n. 3
0
        private static async Task ConnectToMasterRouterAsync(IPAddress address, int port)
        {
            var client = new TcpClient();
            await client.ConnectAsync(address, port);

            var routingClient = new AERoutingClient(client, DatabaseServices.InteropPacketHandler,
                                                    DatabaseServices.IncomingRoutingMiddlewareHandler,
                                                    DatabaseServices.OutgoingRoutingMiddlewareHandler,
                                                    DatabaseServices.ObjectRepository);

            var chbp = new ClientHandshakeBeginPacket
            {
                Protocol  = Constants.LatestAEProtocolVersion,
                Password  = "******",
                Component = new RoutingComponent
                {
                    Type = ComponentType.DatabaseComponent
                }
            };

            await routingClient.SendDataAsync(chbp.FinalizePacket());

            await routingClient.ListenForDataTask();

            DatabaseServices.ObjectRepository.RemoveObject(routingClient.ClientGuid);
        }