mirror of
https://github.com/glest/glest-source.git
synced 2025-08-10 02:16:31 +02:00
Ported LAN auto-connect feature to win32
This commit is contained in:
@@ -23,6 +23,14 @@ using std::string;
|
||||
const char* WSAGetLastErrorMessage(const char* pcMessagePrefix,int nErrorID = 0);
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
//
|
||||
// This interface describes the methods a callback object must implement
|
||||
// when signalled with detected servers
|
||||
//
|
||||
class DiscoveredServersInterface {
|
||||
public:
|
||||
virtual void DiscoveredServers(std::vector<string> serverList) = 0;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class IP
|
||||
@@ -81,6 +89,7 @@ public:
|
||||
int peek(void *data, int dataSize);
|
||||
|
||||
void setBlock(bool block);
|
||||
static void setBlock(bool block, SOCKET socket);
|
||||
bool isReadable();
|
||||
bool isWritable(bool waitOnDelayedResponse);
|
||||
bool isConnected();
|
||||
@@ -93,14 +102,48 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class BroadCastClientSocketThread : public Thread
|
||||
{
|
||||
private:
|
||||
Mutex mutexRunning;
|
||||
Mutex mutexQuit;
|
||||
|
||||
bool quit;
|
||||
bool running;
|
||||
|
||||
DiscoveredServersInterface *discoveredServersCB;
|
||||
|
||||
void setRunningStatus(bool value);
|
||||
void setQuitStatus(bool value);
|
||||
|
||||
public:
|
||||
BroadCastClientSocketThread(DiscoveredServersInterface *cb);
|
||||
virtual void execute();
|
||||
void signalQuit();
|
||||
bool getQuitStatus();
|
||||
bool getRunningStatus();
|
||||
};
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class ClientSocket
|
||||
// =====================================================
|
||||
|
||||
class ClientSocket: public Socket{
|
||||
public:
|
||||
ClientSocket();
|
||||
virtual ~ClientSocket();
|
||||
|
||||
void connect(const Ip &ip, int port);
|
||||
static std::vector<string> discoverServers();
|
||||
static void discoverServers(DiscoveredServersInterface *cb);
|
||||
|
||||
static void stopBroadCastClientThread();
|
||||
|
||||
protected:
|
||||
|
||||
static BroadCastClientSocketThread *broadCastClientThread;
|
||||
static void startBroadCastClientThread(DiscoveredServersInterface *cb);
|
||||
};
|
||||
|
||||
class BroadCastSocketThread : public Thread
|
||||
|
Reference in New Issue
Block a user