Danbias/Code/Network/NetworkDependencies/ThreadedClient.h

53 lines
1.4 KiB
C
Raw Normal View History

#ifndef NETWORK_DEPENDENCIES_THREADED_CLIENT_H
#define NETWORK_DEPENDENCIES_THREADED_CLIENT_H
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#include "../../Misc/Thread/IThreadObject.h"
2013-12-08 23:56:17 +01:00
#include "PostBox.h"
#include "Connection.h"
#include "../../Misc/Thread/OysterThread.h"
#include "../../Misc/Thread/OysterMutex.h"
#include "../../Misc/Utilities.h"
namespace Oyster
{
namespace Network
{
2013-12-08 23:56:17 +01:00
class OysterByte;
class ThreadedClient : public Thread::IThreadObject
{
public:
ThreadedClient();
ThreadedClient(unsigned int socket);
2013-12-08 23:56:17 +01:00
ThreadedClient(IPostBox<Utility::DynamicMemory::SmartPointer<OysterByte>> *postBox, unsigned int socket);
virtual ~ThreadedClient();
2013-12-08 23:56:17 +01:00
int Send(Utility::DynamicMemory::SmartPointer<OysterByte>& byte);
int Connect(unsigned short port, const char serverName[]);
2013-12-08 23:56:17 +01:00
void setRecvPostBox(IPostBox<Utility::DynamicMemory::SmartPointer<OysterByte>> *postBox);
private:
virtual int Send();
virtual int Recv();
virtual void ThreadEntry();
virtual void ThreadExit();
virtual bool DoWork();
private:
Connection* connection;
IPostBox<Utility::DynamicMemory::SmartPointer<OysterByte>> *sendPostBox;
IPostBox<Utility::DynamicMemory::SmartPointer<OysterByte>> *recvPostBox;
Oyster::Thread::OysterThread thread;
OysterMutex mutex;
};
}
}
#endif