Added GUI as parameter for client thread constructor. Fixed linux header for getaddrinfo.
This commit is contained in:
@@ -27,11 +27,12 @@
|
||||
|
||||
class ClientData;
|
||||
class ClientState;
|
||||
class GuiInterface;
|
||||
|
||||
class ClientThread : public Thread
|
||||
{
|
||||
public:
|
||||
ClientThread();
|
||||
ClientThread(GuiInterface &gui);
|
||||
virtual ~ClientThread();
|
||||
|
||||
// Set the parameters. Does not do any error checking.
|
||||
@@ -47,13 +48,15 @@ protected:
|
||||
const ClientData &GetData() const;
|
||||
ClientData &GetData();
|
||||
|
||||
ClientState &GetState();
|
||||
void SetState(ClientState &newState);
|
||||
|
||||
private:
|
||||
|
||||
std::auto_ptr<ClientData> m_data;
|
||||
|
||||
ClientState *m_curState;
|
||||
GuiInterface &m_gui;
|
||||
|
||||
|
||||
friend class ClientStateInit;
|
||||
friend class ClientStateResolve;
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
ClientThread::ClientThread()
|
||||
: m_curState(NULL)
|
||||
ClientThread::ClientThread(GuiInterface &gui)
|
||||
: m_curState(NULL), m_gui(gui)
|
||||
{
|
||||
m_data.reset(new ClientData);
|
||||
m_curState = &CLIENT_INITIAL_STATE::Instance();
|
||||
@@ -53,6 +53,7 @@ ClientThread::Main()
|
||||
{
|
||||
while (!ShouldTerminate())
|
||||
{
|
||||
GetState().Process(*this, m_gui);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +71,13 @@ ClientThread::GetData()
|
||||
return *m_data;
|
||||
}
|
||||
|
||||
ClientState &
|
||||
ClientThread::GetState()
|
||||
{
|
||||
assert(m_curState);
|
||||
return *m_curState;
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::SetState(ClientState &newState)
|
||||
{
|
||||
|
||||
@@ -29,12 +29,12 @@ socket_set_port(unsigned port, int addrFamily, struct sockaddr *addr, int addrLe
|
||||
|
||||
if (addr)
|
||||
{
|
||||
if (addrFamily == AF_INET && addrLen >= sizeof(sockaddr_in))
|
||||
if (addrFamily == AF_INET && addrLen >= (int)sizeof(sockaddr_in))
|
||||
{
|
||||
((sockaddr_in *)&addr)->sin_port = htons(port);
|
||||
retVal = true;
|
||||
}
|
||||
else if (addrFamily == AF_INET6 && addrLen >= sizeof(sockaddr_in6))
|
||||
else if (addrFamily == AF_INET6 && addrLen >= (int)sizeof(sockaddr_in6))
|
||||
{
|
||||
((sockaddr_in6 *)&addr)->sin6_port = htons(port);
|
||||
retVal = true;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user