Sending real ip address, port and server name.

This commit is contained in:
Pontus Fransson 2014-02-23 21:15:16 +01:00
parent be1c3e2af0
commit 0cb7940bae
2 changed files with 16 additions and 2 deletions

View File

@ -20,6 +20,9 @@
#include <WinTimer.h>
#include <thread>
//For conversion from wstring to string
#include <codecvt>
using namespace DanBias;
using namespace Oyster::Network;
using namespace Oyster::Thread;
@ -43,6 +46,11 @@ namespace
}
std::string wstring_to_utf8 (const std::wstring& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
return myconv.to_bytes(str);
}
DanBiasServerReturn GameServerAPI::ServerInitiate(const ServerInitDesc& desc)
{
@ -50,7 +58,9 @@ DanBiasServerReturn GameServerAPI::ServerInitiate(const ServerInitDesc& desc)
opt.mainOptions.listenPort = desc.listenPort;
opt.mainOptions.ownerSession = &lobby;
GameLogic::Protocol_Broadcast_Test broadcastMessage(opt.mainOptions.listenPort, "127.0.0.1", "ServerName");
std::string serverName = wstring_to_utf8(desc.serverName);
GameLogic::Protocol_Broadcast_Test broadcastMessage(opt.mainOptions.listenPort, "127.0.0.1", serverName);
opt.broadcastOptions.broadcast = true;
opt.broadcastOptions.broadcastInterval = 1.0f;
@ -64,6 +74,9 @@ DanBiasServerReturn GameServerAPI::ServerInitiate(const ServerInitDesc& desc)
std::printf("Server created!\t-\t%s: [%i]\n\n", server.GetLanAddress().c_str(), desc.listenPort);
GameLogic::Protocol_Broadcast_Test broadcastMessage2(opt.mainOptions.listenPort, server.GetLanAddress(), serverName);
server.SetBroadcastMessage(broadcastMessage2.GetProtocol());
return DanBiasServerReturn_Sucess;
}
void GameServerAPI::ServerStart()

View File

@ -133,6 +133,7 @@ struct NetworkClient::PrivateData : public IThreadObject
CloseHandle(shutdownEvent);
}
//Thread for receiving broadcast messages
void BroadcastThread()
{
WSANETWORKEVENTS wsaEvents;