public static void Main(string[] args) { var endPoint = ProtocolEndPointBase.CreateEndPoint("tcp://127.0.0.1:13378"); _server = ServiceBuilder.CreateService(endPoint); _server.AddService <ITestServerService, TestServerService>(new TestServerService()); _server.ClientConnected += ServerOnClientConnected; _server.ClientDisconnected += ServerOnClientDisconnected; _server.Start(); ServerConsole.DebugLine("Service running on {0}", endPoint); 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 inter-server v{0}.{1}", ver.Major, ver.Minor); ServerConsole.StatusLine(Console.Title); // Create a service var endPointAddress = string.Format("tcp://{0}:{1}", dynamicConfig.network.host, dynamicConfig.network.port); _server = ServiceBuilder.CreateService(ProtocolEndPointBase.CreateEndPoint(endPointAddress)); // Add interface for auth-server _server.AddService <IAuthService, AuthServiceImplementation>(new AuthServiceImplementation(dynamicConfig)); // Add interface for world-server _server.AddService <IWorldService, WorldServiceImplementation>(new WorldServiceImplementation(dynamicConfig)); // Start listener service _server.Start(); ServerConsole.StatusLine("Inter-server is listening to: {0}", endPointAddress); do { var cmd = Console.ReadLine(); if (cmd == "exit") { _server.Stop(); } } while (_server.Connected); ServerConsole.WarningLine("Press any key to exit."); Console.Read(); }
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(); }
/// <summary> /// Creates a new client to connect to a server using an end point. /// </summary> /// <param name="endpointAddress">End point address of the server to connect it</param> /// <returns>Created TCP client</returns> public static IClient CreateClient(string endpointAddress) { return(CreateClient(ProtocolEndPointBase.CreateEndPoint(endpointAddress))); }
/// <summary> /// Creates a client to connect to a ZCF service. /// </summary> /// <typeparam name="T">Type of service interface for remote method call</typeparam> /// <param name="endpointAddress">EndPoint address of the server</param> /// <param name="clientObject"> /// Client-side object that handles remote method calls from server to client. /// May be null if client has no methods to be invoked by server /// </param> /// <returns>Created client object to connect to the server</returns> public static IServiceClient <T> CreateClient <T>(string endpointAddress, object clientObject = null) where T : class { return(CreateClient <T>(ProtocolEndPointBase.CreateEndPoint(endpointAddress), clientObject)); }
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(); }