From 3c681352da896cfa68a95f2438f686c60bad2574 Mon Sep 17 00:00:00 2001 From: Sam Mario Svensson Date: Fri, 29 Nov 2013 09:18:58 +0100 Subject: [PATCH] Documentation of the code done by Sam --- Code/Misc/IQueue.h | 4 ++++ Code/Misc/ThreadSafeQueue.h | 4 +++- Code/Network/NetworkDependencies/Connection.h | 2 ++ Code/Network/NetworkDependencies/IConnection.h | 14 +++++++++++++- Code/Network/NetworkDependencies/ITranslate.h | 1 + Code/Network/NetworkDependencies/Protocols.h | 10 +++++++--- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Code/Misc/IQueue.h b/Code/Misc/IQueue.h index 8ddc28a9..fc85800e 100644 --- a/Code/Misc/IQueue.h +++ b/Code/Misc/IQueue.h @@ -13,6 +13,10 @@ namespace Oyster class IQueue { public: + + //--------------------------------------------- + //standard operations of the std::queue + //--------------------------------------------- virtual ~IQueue() {}; virtual void Push( Type item ) = 0; virtual Type Pop() = 0; diff --git a/Code/Misc/ThreadSafeQueue.h b/Code/Misc/ThreadSafeQueue.h index 019485ce..d0125f71 100644 --- a/Code/Misc/ThreadSafeQueue.h +++ b/Code/Misc/ThreadSafeQueue.h @@ -3,7 +3,9 @@ //////////////////////////////////////////// // Thread safe queue implemented -// with single linked list. +// with single linked list and template. +// uses mutex to lock the queue +// otherwise its a standard queue // Created by Sam Svensson 2013 ///////////////////////////////////////////// diff --git a/Code/Network/NetworkDependencies/Connection.h b/Code/Network/NetworkDependencies/Connection.h index c69bb0f5..b46ccb02 100644 --- a/Code/Network/NetworkDependencies/Connection.h +++ b/Code/Network/NetworkDependencies/Connection.h @@ -20,6 +20,7 @@ namespace Oyster Connection( int socket ) { this->socket = socket; }; virtual ~Connection(); + virtual int InitiateServer( unsigned short port ); virtual int InitiateClient(); @@ -28,6 +29,7 @@ namespace Oyster virtual int Disconnect(); virtual int Connect( unsigned short port , const char serverName[] ); + virtual int Listen(); private: diff --git a/Code/Network/NetworkDependencies/IConnection.h b/Code/Network/NetworkDependencies/IConnection.h index 2ca895b1..5f88932b 100644 --- a/Code/Network/NetworkDependencies/IConnection.h +++ b/Code/Network/NetworkDependencies/IConnection.h @@ -14,13 +14,25 @@ namespace Oyster { public: - virtual int Disconnect() = 0; + + //sends and recieve functions with bytearrays, + //will send to the users connection via socket virtual int Send( OysterByte& bytes ) = 0; virtual int Recieve( OysterByte& bytes) = 0; + + //initiates sockets and address for server and client virtual int InitiateServer( unsigned short port ) { return false; }; virtual int InitiateClient() { return false; }; + + //Listen function to let client connect, only used by the server virtual int Listen() { return -1; }; + + //enables the client to connect with a server with use of name and port + //(servers uses Listen instead of connect) virtual int Connect( unsigned short port, const char serverName[] ) { return false; }; + + //Disconnects the client or server TODO: optimize! + virtual int Disconnect() = 0; }; } } diff --git a/Code/Network/NetworkDependencies/ITranslate.h b/Code/Network/NetworkDependencies/ITranslate.h index 90eb1431..80edc8b1 100644 --- a/Code/Network/NetworkDependencies/ITranslate.h +++ b/Code/Network/NetworkDependencies/ITranslate.h @@ -14,6 +14,7 @@ namespace Oyster { public: + //packs and unpacks packages for sending or recieving over the connection virtual void Pack (Protocols::ProtocolHeader &header, OysterByte& bytes) = 0; virtual void Unpack (Protocols::ProtocolSet* set, OysterByte& bytes ) = 0; diff --git a/Code/Network/NetworkDependencies/Protocols.h b/Code/Network/NetworkDependencies/Protocols.h index 12444e3e..8defcfb3 100644 --- a/Code/Network/NetworkDependencies/Protocols.h +++ b/Code/Network/NetworkDependencies/Protocols.h @@ -1,9 +1,13 @@ #ifndef NETWORK_DEPENDENCIES_PROTOCOLS_H #define NETWORK_DEPENDENCIES_PROTOCOLS_H -////////////////////////////////// -// Created by Sam Svensson 2013 // -////////////////////////////////// +////////////////////////////////////// +// Created by Sam Svensson 2013 +// Holder structs for our protocols +// with the use of union. +// each packagetyp +// is linked to a protocol +////////////////////////////////////// #include