2013-11-25 11:39:38 +01:00
|
|
|
#ifndef NETWORK_DEPENDENCIES_CONNECTION_H
|
|
|
|
#define NETWORK_DEPENDENCIES_CONNECTION_H
|
|
|
|
|
2013-11-19 12:38:13 +01:00
|
|
|
//////////////////////////////////
|
|
|
|
// Created by Sam Svensson 2013 //
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
#include "IConnection.h"
|
2013-11-27 11:01:22 +01:00
|
|
|
#include "../NetworkDependencies/OysterByte.h"
|
2013-11-19 12:38:13 +01:00
|
|
|
|
2013-11-21 13:40:52 +01:00
|
|
|
namespace Oyster
|
2013-11-19 12:38:13 +01:00
|
|
|
{
|
2013-11-21 13:40:52 +01:00
|
|
|
namespace Network
|
|
|
|
{
|
|
|
|
class Connection : public IConnection
|
|
|
|
{
|
|
|
|
public:
|
2013-12-04 12:41:25 +01:00
|
|
|
Connection();
|
|
|
|
Connection( int socket );
|
2013-11-25 11:39:38 +01:00
|
|
|
virtual ~Connection();
|
2013-11-21 13:40:52 +01:00
|
|
|
|
2013-11-26 13:45:03 +01:00
|
|
|
virtual int InitiateServer( unsigned short port );
|
|
|
|
virtual int InitiateClient();
|
2013-11-22 08:54:26 +01:00
|
|
|
|
2013-12-13 23:47:16 +01:00
|
|
|
virtual int Send( OysterByte &bytes );
|
|
|
|
virtual int Recieve( OysterByte &bytes );
|
2013-11-22 08:54:26 +01:00
|
|
|
|
2013-11-26 13:45:03 +01:00
|
|
|
virtual int Disconnect();
|
2014-01-29 15:01:14 +01:00
|
|
|
virtual int Connect(ConnectionInfo info, bool blocking = false);
|
2014-01-28 09:00:02 +01:00
|
|
|
virtual int Connect(unsigned short port , const char serverName[], bool blocking = false);
|
2014-02-19 09:25:40 +01:00
|
|
|
virtual int Reconnect();
|
2013-11-29 09:18:58 +01:00
|
|
|
|
2014-01-29 15:01:14 +01:00
|
|
|
virtual ConnectionInfo Listen();
|
2013-11-21 13:40:52 +01:00
|
|
|
|
2013-12-11 21:45:43 +01:00
|
|
|
bool IsSending();
|
|
|
|
bool IsConnected();
|
|
|
|
|
2013-12-03 23:12:48 +01:00
|
|
|
//Setting the socket to blocking/non-blocking mode.
|
|
|
|
int SetBlockingMode( bool blocking );
|
|
|
|
|
2014-01-29 15:01:14 +01:00
|
|
|
std::string GetIpAddress();
|
2014-02-22 22:38:28 +01:00
|
|
|
int GetSocket();
|
|
|
|
|
2014-01-29 15:01:14 +01:00
|
|
|
|
2013-11-21 13:40:52 +01:00
|
|
|
private:
|
2013-11-27 11:28:11 +01:00
|
|
|
int InitiateSocket();
|
2013-11-25 14:03:32 +01:00
|
|
|
|
2013-11-25 11:39:38 +01:00
|
|
|
int socket;
|
2013-11-21 13:40:52 +01:00
|
|
|
|
2013-12-04 12:41:25 +01:00
|
|
|
bool stillSending;
|
|
|
|
bool closed;
|
2014-01-29 15:01:14 +01:00
|
|
|
std::string addr;
|
2014-02-19 09:25:40 +01:00
|
|
|
|
|
|
|
std::string lastConnectAddr;
|
|
|
|
unsigned short lastConnectPort;
|
|
|
|
|
|
|
|
bool blocking;
|
2013-11-21 13:40:52 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2013-11-19 12:38:13 +01:00
|
|
|
|
|
|
|
#endif
|