Network - Overloaded Connect in NetworkClient to use std::wstring.

This commit is contained in:
Pontus Fransson 2014-02-13 13:51:27 +01:00
parent bd6b531418
commit 95e08e84c3
2 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,9 @@
#include <queue> #include <queue>
#include <WinSock2.h> #include <WinSock2.h>
//For conversion from wstring to string
#include <codecvt>
using namespace Oyster::Network; using namespace Oyster::Network;
using namespace Oyster::Thread; using namespace Oyster::Thread;
using namespace Utility::DynamicMemory; using namespace Utility::DynamicMemory;
@ -293,6 +296,17 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[])
return true; return true;
} }
bool NetworkClient::Connect(unsigned short port, std::wstring serverIP)
{
//Convert from wstring to string.
typedef std::codecvt_utf8<wchar_t> convert_typeX;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::string ip = converterX.to_bytes(serverIP);
return this->Connect(port, ip.c_str());
}
void NetworkClient::Disconnect() void NetworkClient::Disconnect()
{ {
if(!privateData) return; if(!privateData) return;

View File

@ -88,6 +88,11 @@ namespace Oyster
*/ */
bool Connect(unsigned short port, const char serverIP[]); bool Connect(unsigned short port, const char serverIP[]);
/**
*
*/
bool Connect(unsigned short port, std::wstring serverIP);
/** /**
* *
*/ */