public CommunicationHandler(TcpClient serverCon, IErrorHandler error, IInvokable invoke, INotifiable notify, ILobby lobby) { _errorHandler = error; _tcpClient = serverCon; _tcpClient.DataReceived += TcpClient_DataReceived; _tcpClient.Disconnected += TcpClient_Disconnnected; _tcpClient.Start(); _processor = new DataProcessor(invoke, notify, lobby); }
private void SocketAccepted(SocketAcceptedEventArgs e) { IPEndPoint sender = (IPEndPoint)e.Socket.RemoteEndPoint; Console.WriteLine("Client connected at address : {0}:{1}", sender.Address, sender.Port); TcpClient tcpClient = new TcpClient(e.Socket); tcpClient.DataReceived += TcpClient_DataReceived; tcpClient.Disconnected += Client_Disconnected; tcpClient.Start(); }