Started implementing broadcasting

This commit is contained in:
Pontus Fransson 2014-02-21 09:34:09 +01:00
parent 708526a54b
commit c718dc5a2b
2 changed files with 28 additions and 11 deletions

View File

@ -591,7 +591,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
case protocol_Gameplay_ObjectDie: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectDisconnectPlayer:
{
//Removes
//Remove the disconnected player
Protocol_ObjectDisconnectPlayer decoded(data);
auto object = this->privData->dynamicObjects->find( decoded.objectID );
if( object != this->privData->dynamicObjects->end() )

View File

@ -22,16 +22,16 @@ namespace Oyster
{
struct BroadcastOptions
{
//bool broadcast;
//float broadcastInterval;
//std::wstring subnetToBroadcast;
//CustomNetProtocol broadcastMessage;
//BroadcastOptions()
//{
// broadcast = true;
// broadcastInterval = 1.0f;
// subnetToBroadcast = L"192.168.0.1";
//}
bool broadcast;
float broadcastInterval;
std::wstring subnetToBroadcast;
CustomNetProtocol broadcastMessage;
BroadcastOptions()
{
broadcast = true;
broadcastInterval = 1.0f;
subnetToBroadcast = L"192.168.0.1";
}
} broadcastOptions;
struct MainOptions
@ -117,6 +117,23 @@ namespace Oyster
*/
int NetworkServer::GetPort();
/***************************************
Broadcast functions
***************************************/
//Set broadcast settings.
void SetBroadcast(CustomNetProtocol& broadcastMessage, float interval = 1.0f, bool enable = true);
//Set broadcast settings.
void SetBroadcastMessage(CustomNetProtocol& broadcastMessage);
//Enable/disable broadcast.
void SetBroadcast(bool enable);
//Set interval between each broadcast message in seconds.
void SetBroadcastInterval(float interval);
private:
struct PrivateData;
PrivateData* privateData;