Support UDP discovery broadcast packets (so we can list servers)
This commit is contained in:
@@ -47,6 +47,8 @@ bool StepManiaLanServer::ServerStart()
|
|||||||
if (server.bind(8765))
|
if (server.bind(8765))
|
||||||
if (server.listen())
|
if (server.listen())
|
||||||
{
|
{
|
||||||
|
broadcast.create( IPPROTO_UDP );
|
||||||
|
broadcast.connect( "255.255.255.255", 8765 );
|
||||||
stop = false;
|
stop = false;
|
||||||
statsTime = time(NULL);
|
statsTime = time(NULL);
|
||||||
return true;
|
return true;
|
||||||
@@ -84,6 +86,7 @@ void StepManiaLanServer::ServerUpdate()
|
|||||||
UpdateClients();
|
UpdateClients();
|
||||||
if (time(NULL) > statsTime)
|
if (time(NULL) > statsTime)
|
||||||
{
|
{
|
||||||
|
BroadcastInfo();
|
||||||
SendStatsToClients();
|
SendStatsToClients();
|
||||||
statsTime = time(NULL);
|
statsTime = time(NULL);
|
||||||
}
|
}
|
||||||
@@ -993,10 +996,22 @@ void StepManiaLanServer::CheckLowerJudge(const unsigned int clientNum)
|
|||||||
Client[clientNum]->lowerJudge = true;
|
Client[clientNum]->lowerJudge = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StepManiaLanServer::BroadcastInfo()
|
||||||
|
{
|
||||||
|
PacketFunctions Binfo;
|
||||||
|
Binfo.ClearPacket();
|
||||||
|
Binfo.WriteNT( servername );
|
||||||
|
Binfo.Write2( 8765 );
|
||||||
|
Binfo.Write2( Client.size() );
|
||||||
|
|
||||||
|
broadcast.SendPack( (char*)&Binfo.Data, Binfo.Position );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Joshua Allen
|
* (c) 2003-2005 Joshua Allen, Charles Lohr
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ private:
|
|||||||
PacketFunctions Reply;
|
PacketFunctions Reply;
|
||||||
vector<GameClient*> Client;
|
vector<GameClient*> Client;
|
||||||
EzSockets server;
|
EzSockets server;
|
||||||
|
EzSockets broadcast;
|
||||||
int ClientHost;
|
int ClientHost;
|
||||||
vector<LanPlayer*> playersPtr;
|
vector<LanPlayer*> playersPtr;
|
||||||
time_t statsTime;
|
time_t statsTime;
|
||||||
@@ -136,6 +137,7 @@ private:
|
|||||||
void Disconnect(const unsigned int clientNum);
|
void Disconnect(const unsigned int clientNum);
|
||||||
void ClientsSongSelectStart();
|
void ClientsSongSelectStart();
|
||||||
void ResetLastSongInfo();
|
void ResetLastSongInfo();
|
||||||
|
void BroadcastInfo();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user