From 95e08e84c3a4a831beaaccb4aa26b21c01de5b63 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 13 Feb 2014 13:51:27 +0100 Subject: [PATCH] Network - Overloaded Connect in NetworkClient to use std::wstring. --- Code/Network/NetworkAPI/NetworkClient.cpp | 14 ++++++++++++++ Code/Network/NetworkAPI/NetworkClient.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 01ba495e..1f470c11 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -21,6 +21,9 @@ #include #include +//For conversion from wstring to string +#include + using namespace Oyster::Network; using namespace Oyster::Thread; using namespace Utility::DynamicMemory; @@ -293,6 +296,17 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[]) return true; } +bool NetworkClient::Connect(unsigned short port, std::wstring serverIP) +{ + //Convert from wstring to string. + typedef std::codecvt_utf8 convert_typeX; + std::wstring_convert converterX; + + std::string ip = converterX.to_bytes(serverIP); + + return this->Connect(port, ip.c_str()); +} + void NetworkClient::Disconnect() { if(!privateData) return; diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index a19f74e4..b7e0d6a4 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -88,6 +88,11 @@ namespace Oyster */ bool Connect(unsigned short port, const char serverIP[]); + /** + * + */ + bool Connect(unsigned short port, std::wstring serverIP); + /** * */