//Default constructor public ServerCommunicationManager() { this.isConnected = false; this.bufferSize = BUFFER_SIZE; this.buffer = new char[this.bufferSize]; tRoboCupConnection = null; this.hostName = ""; this.port = 0; Console.WriteLine("[+]SUCCESS: \tServerCommunicationManager.ServerCommunicationManager(): Successfully initialized ServerCommunicationManager."); }
//Returns 'true' if agent succesfully connects to server public bool connect(string serverIP, int serverPort) { if (this.isConnected == true) { Console.WriteLine("[!]INFO:\t ServerCommunicationManager.connect(string, int): Already connected to server."); return(true); } this.tRoboCupConnection = new TRoboCupConnection(ConnectionType.CONNECTION_TCP, serverIP, serverPort); if (this.tRoboCupConnection != null) { this.isConnected = true; Console.WriteLine("[+]SUCCESS:\t ServerCommunicationManager.connect(string, int): Connection with server established."); return(true); } Console.WriteLine("[-]ERROR:\t ServerCommunicationManager.connect(string, int): Cannot connect to server."); return(false); }