private void DoWork(object port) { serverConnection = new ServerSideConnection((int)port, RECEIVE_BUFFER_SIZE, new MinesweeperCommandConverter()); while (serverConnection.WaitForIncomingConnection()) { model.OnAgentConnected(); sender = serverConnection.GetTcpCommandSender(); receiver = serverConnection.GetTcpCommandReceiver(); if (ReceiveInitializationMessage()) { RepetetiveWork(); } } }
public bool Connect(string serverIpAddress, int port) { currentServerAddress = serverIpAddress; currentServerPort = port; clientConnection = new ClientSideConnection(BUFFER_SIZE, BUFFER_SIZE, new TcpCommunications.MinesweeperCommands.MinesweeperCommandConverter()); if (clientConnection.Connect(currentServerAddress, currentServerPort)) { sender = clientConnection.GetTcpCommandSender(); receiver = clientConnection.GetTcpCommandReceiver(); return(true); } return(false); }