public static void Main(string[] args) { var endPoint = ProtocolEndPointBase.CreateEndPoint("tcp://127.0.0.1:6900"); _client = new TestClientImplementation(); _serviceClient = ServiceClientBuilder.CreateClient <ITestServerService>(endPoint, _client); _serviceClient.Connected += ClientOnConnected; _serviceClient.Disconnected += ClientOnDisconnected; _serviceClient.Connect(); do { var cmd = Console.ReadLine(); if (cmd == "exit") { _serviceClient.Disconnect(); } if (cmd == "void") { _serviceClient.ServiceProxy.RemoteVoid(); } if (cmd == "magic") { var poco = new SimplePoco { Id = 1, Title = "My POCO obj" }; _serviceClient.ServiceProxy.SomeRemoteMagic(poco); } if (cmd == "ex") { _serviceClient.ServiceProxy.RaiseTheException(); } } while (_serviceClient.CommunicationState == CommunicationStates.Connected); Console.WriteLine("Press any key to exit."); Console.Read(); }
public static void Main(string[] args) { var serverConfiguration = Factory.Create <Provider>("conf/client.xml"); var dynamicConfig = serverConfiguration.FirstAsExpando().configuration; string address = string.Format("tcp://{0}:{1}", dynamicConfig.zeus.host, dynamicConfig.zeus.port); var endPoint = ProtocolEndPointBase.CreateEndPoint(address); _service = ServiceClientBuilder.CreateClient <IClientService>(endPoint); _service.Connected += (o, a) => Console.WriteLine("Connection to auth-server successfull!"); _service.Disconnected += (o, a) => Console.WriteLine("Connection to inter-server lost."); _service.ConnectTimeout = 30; _service.Connect(); do { var cmd = Console.ReadLine(); if (cmd == "exit") { _service.Disconnect(); } if (cmd == "login") { var account = _service.ServiceProxy.ClientLogin("test", "test"); Console.WriteLine("Got account info: {0}", account); } if (cmd == "servers") { var servers = _service.ServiceProxy.GetServerDescriptions(); Console.WriteLine("Got server info:"); servers.ToList().ForEach(s => Console.WriteLine("\t{0}", s)); } } while (_service.CommunicationState == CommunicationStates.Connected); Console.WriteLine("Press any key to exit."); Console.Read(); }
public static void Main(string[] args) { // Try access a config var serverConfiguration = Factory.Create <Provider>("conf/server.xml"); var dynamicConfig = serverConfiguration.FirstAsExpando().configuration; // Prepare console for a large output #if WINDOWS var width = Math.Min(100, Console.LargestWindowWidth - 2); Console.CursorVisible = false; Console.Clear(); Console.WindowLeft = Console.WindowTop = 0; if (Console.WindowWidth < width) { Console.WindowWidth = width; } #endif var ver = Assembly.GetExecutingAssembly().GetName().Version; Console.Title = string.Format("Zeus auth-server v{0}.{1}", ver.Major, ver.Minor); ServerConsole.StatusLine(Console.Title); // Create inter-server listener service string interServerEndPointAddress = string.Format("tcp://{0}:{1}", dynamicConfig.network.inter_server.host, dynamicConfig.network.inter_server.port); var interServerEndPoint = ProtocolEndPointBase.CreateEndPoint(interServerEndPointAddress); ServerConsole.Info("Start connecting to inter-server.."); // @TODO: Is any action coming from inter-server to auth-server? // @TODO: Create inter -> auth service (character goes back to char select) _interClient = ServiceClientBuilder.CreateClient <IAuthService>(interServerEndPoint, new ServerServiceImplementation()); _interClient.Connected += (o, a) => { ServerConsole.WriteLine(ServerConsoleColor.Status, " successfull!"); // AuthServerLogin _interClient.ServiceProxy.AuthServerLogin((string)dynamicConfig.network.inter_server.password); }; _interClient.Disconnected += delegate { ServerConsole.ErrorLine("Connection to inter-server lost."); // @TODO: Reconnect? }; _interClient.ConnectTimeout = 30; _interClient.Connect(); // Create a client listener service string endPointAddress = string.Format("tcp://{0}:{1}", dynamicConfig.network.host, dynamicConfig.network.port); _clientService = ServiceBuilder.CreateService(ProtocolEndPointBase.CreateEndPoint(endPointAddress)); _clientService.ClientConnected += (sender, clientEventArgs) => ServerConsole.DebugLine("Client connected #{0}", clientEventArgs.Client.ClientId); _clientService.ClientDisconnected += (sender, clientEventArgs) => ServerConsole.DebugLine("Client disconnected #{0}", clientEventArgs.Client.ClientId); // Add interface for client connections var clientService = new ClientServiceImplementation(_interClient.ServiceProxy); _clientService.AddService <IClientService, ClientServiceImplementation>(clientService); // Start listener service _clientService.Start(); ServerConsole.StatusLine("Auth-server is listening to: {0}", endPointAddress); do { var cmd = Console.ReadLine(); if (cmd == "exit") { _clientService.Stop(); } } while (_clientService.Connected); ServerConsole.WarningLine("Press any key to exit."); Console.Read(); }