public ConnectionModel(Socket socket, ConnectionManager manager, MessageHandler messageHandler) { if (socket == null) throw new ArgumentNullException(nameof(socket)); if (messageHandler == null) throw new ArgumentNullException(nameof(messageHandler)); Id = Guid.NewGuid(); _buffer = new Byte[1024]; _socket = socket; _manager = manager; _messageHandler = messageHandler; _logger.Debug($"New ConnectionModel created. Id: '{Id}'"); _socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, OnReceive, null); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; String serverIp = ConfigurationManager.AppSettings["ServerIp"]; String serverPort = ConfigurationManager.AppSettings["ServerPort"]; Logger.Info($"Server will try to listen on {serverIp}:{serverPort}"); EndPoint endPoint = new IPEndPoint(IPAddress.Parse(serverIp), UInt16.Parse(serverPort)); using (ConnectionManager manager = new ConnectionManager(new ConnectionListener(endPoint), new MessageHandler())) { ConnectionManager = manager; Console.WriteLine("Press <Escape> to exit"); while (Console.ReadKey().Key == ConsoleKey.Escape) { } } }
public Service(int port) { _port = port; _connectionManager = new ConnectionManager(port); _clientManager = new ClientManager(_connectionManager); }
public ClientManager(ConnectionManager connectionManager) { _connectionManager = connectionManager; }