Added documentation and removed unecessesary code.

This commit is contained in:
Pontus Fransson 2013-11-29 09:11:30 +01:00
parent 1cbdb0bcfa
commit 407f3c5c9a
7 changed files with 11 additions and 33 deletions

View File

@ -4,6 +4,7 @@ using namespace Oyster::Network::Server;
Listener::Listener() Listener::Listener()
{ {
connection = NULL;
} }
Listener::~Listener() Listener::~Listener()

View File

@ -25,8 +25,7 @@ namespace Oyster
bool Init(unsigned int port); bool Init(unsigned int port);
void Shutdown(); void Shutdown();
int Accept();
int GetNewClient();
void SetPostBox(IPostBox<int>* postBox); void SetPostBox(IPostBox<int>* postBox);
//Thread functions //Thread functions
@ -35,6 +34,8 @@ namespace Oyster
void ThreadExit(); void ThreadExit();
private: private:
//Function that runs in the thread.
int Accept();
private: private:

View File

@ -30,8 +30,6 @@ namespace Oyster
operator char*(); operator char*();
operator const char*(); operator const char*();
operator unsigned char*(); operator unsigned char*();
//unsigned char& operator[](unsigned int id);
private: private:
void IncreaseCapacity(unsigned int cap); //Expands the byteArray void IncreaseCapacity(unsigned int cap); //Expands the byteArray

View File

@ -13,6 +13,8 @@ namespace Oyster
{ {
namespace Network namespace Network
{ {
//With this class you can post items to it and then fetch them somewhere else.
//It is thread safe beacause of the ThreadSafeQueue.
template <class T> template <class T>
class PostBox : public IPostBox<T> class PostBox : public IPostBox<T>
{ {

View File

@ -41,6 +41,9 @@ namespace Oyster
virtual ~ProtocolTest() { delete[] f; } virtual ~ProtocolTest() { delete[] f; }
}; };
//Holding every protocol in an union.
//Used because we now don't have to type case our protocol when we recieve them.
class ProtocolSet class ProtocolSet
{ {
public: public:

View File

@ -4,8 +4,8 @@
///////////////////////////////////// /////////////////////////////////////
// Created by Pontus Fransson 2013 // // Created by Pontus Fransson 2013 //
///////////////////////////////////// /////////////////////////////////////
#include <string>
#include <string>
void ShutdownWinSock(); void ShutdownWinSock();
bool InitWinSock(); bool InitWinSock();

View File

@ -37,6 +37,7 @@ int main()
listener.Init(9876); listener.Init(9876);
listener.SetPostBox(postBox); listener.SetPostBox(postBox);
Sleep(1000); Sleep(1000);
//Start listening //Start listening
//Accept a client //Accept a client
ProtocolTest test; ProtocolTest test;
@ -84,37 +85,9 @@ int main()
} }
listener.Shutdown(); listener.Shutdown();
/* int clientSocket = listener.Accept();
Client client1(clientSocket);
cout << "First client connected." << endl;
//Accept a client
clientSocket = listener.Accept();
Client client2(clientSocket);
cout << "Second client connected." << endl;
*/
/* /*
ProtocolSet* set = new ProtocolSet; ProtocolSet* set = new ProtocolSet;
ProtocolTest test;
test.clientID = 0;
test.size = 2;
test.textMessage = "hej";
test.numOfFloats = 35;
test.f = new float[test.numOfFloats];
float temp = 395.456f;
for(int i = 0; i < (int)test.numOfFloats; i++)
{
test.f[i] = temp;
temp--;
}
t.Pack(test, recvBuffer);*/
/*
client1.Send(recvBuffer); client1.Send(recvBuffer);
while(1) while(1)