static void Main(string[] args) { InternalServer server = null; try { ConnectionInfo connection = new ConnectionInfo("localhost", 48030, "ServerConsole"); server = new InternalServer(connection.Ip, connection.Port, connection.Application); server.CreateClient <BusinessLogic>(); var bo1 = server.CreateClient <BoProxy>(); server.CreateClient <BusinessLogic>(bo1); server.Start(); while (true) { Thread.Sleep(100); } } catch (Exception e) { ExceptionHandler.Log(e, "Error while starting the OfficeServerConsole ..."); Logger.Info("Press <enter> to exit the program."); Console.ReadLine(); } finally { // Stop the server. server?.Stop(); } }
private void StartServer() { var server = new InternalServer(nextServerId, PipeName); servers.Add(nextServerId, server); server.Connected += OnConnected; server.Message += OnMessage; server.Disconnected += OnDisconnected; nextServerId++; server.Start(); }
private static void Main(string[] args) { var clients = new Dictionary <Socket, Guid>(); InternalServer.MethodRecievedEvent += delegate(ICommunicationServer server, MethodSignatureDto methodSignature) { Console.WriteLine($"Method signature recevied from client: {server.Socket.RemoteEndPoint}"); Console.WriteLine($"Method name: {methodSignature.MethodName}"); Console.WriteLine($"Amount of parameters: {methodSignature.ParameterTypes.Length}"); }; // Adds a handler for the ClientConnectedEvent, this is fired everytime a client connects to the InternalServer EndPoint InternalServer.ClientConnectedEvent += delegate(Socket socket) { Console.WriteLine($"Client connected: {socket.RemoteEndPoint}"); }; // Adds a handler for the ClientIdentificationEvent, this is fired right after a client is connected. InternalServer.ClientIdentificationEvent += delegate(ICommunicationServer server, Guid clientId) { }; // Adds a handler for the MessageRecievedEvent, this is fired everytime the server sucessfully reads a message. InternalServer.MessageRecievedEvent += delegate(ICommunicationServer server, ISocketMessage message) { Console.WriteLine($"Message recieved from client: {server.Socket.RemoteEndPoint}"); Console.WriteLine("---Message start---"); Console.WriteLine($"Message type: {message.MessageType}"); Console.WriteLine($"Message: {message.Message}"); Console.WriteLine("---Message end---"); Console.WriteLine(); }; InternalServer.Start(); StartListening(); ConnectTestClient(); while (true) { Console.WriteLine("Press enter to send example"); ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Enter) { SendExampleMethodSignature(); } Console.WriteLine("\n\n\n"); } }