//------------------------------------------------------------------------ tresult PLUGIN_API ComponentBase::notify (IMessage* message) { if (!message) return kInvalidArgument; if (!strcmp (message->getMessageID (), "TextMessage")) { TChar string[256] = {0}; if (message->getAttributes ()->getString ("Text", string, sizeof (string) / sizeof (char16)) == kResultOk) { char8 cstr[256]; String tmp (string); tmp.copyTo8 (cstr, 0, 255); return receiveText (cstr); } } return kResultFalse; }
Client::Client(const string& newName, const string& ipaddress, int port) { if(ConnectToHost(port,ipaddress.length()<=1?"127.0.0.1":ipaddress.c_str())){ success=true; string welcomeMsg; if(receiveText(welcomeMsg)){ stringstream ss(""); ss<<"Client connected to: "<<welcomeMsg<<" ,IP: "<<ipaddress<<" [port: "<<port<<"]"; wiBackLog::post(ss.str().c_str()); changeName(newName); serverName=welcomeMsg; } } else{ success=false; stringstream ss(""); ss<<"Connecting to server on address: "<<ipaddress<< " [port "<<port<<"] FAILED with: "<<WSAGetLastError(); wiBackLog::post(ss.str().c_str()); } }