Network - Starting to implement correct shutdown connection.

This commit is contained in:
Pontus Fransson 2013-12-04 12:41:25 +01:00
parent df1470eb2c
commit f0dff0b728
3 changed files with 26 additions and 3 deletions

View File

@ -7,6 +7,20 @@
using namespace Oyster::Network; using namespace Oyster::Network;
Connection::Connection()
{
this->socket = 0;
bool stillSending = false;
bool closed = true;
}
Connection::Connection(int socket)
{
this->socket = socket;
bool stillSending = false;
bool closed = true;
}
Connection::~Connection() Connection::~Connection()
{ {
closesocket( this->socket ); closesocket( this->socket );
@ -30,6 +44,9 @@ int Connection::Connect(unsigned short port , const char serverName[])
return WSAGetLastError(); return WSAGetLastError();
} }
closed = false;
stillSending = true;
//connection succesfull! //connection succesfull!
return 0; return 0;
} }
@ -63,6 +80,9 @@ int Connection::InitiateServer(unsigned short port)
return errorCode; return errorCode;
} }
closed = false;
stillSending = true;
//Server started! //Server started!
return 0; return 0;
} }

View File

@ -16,8 +16,8 @@ namespace Oyster
{ {
public: public:
Connection() { this->socket = 0; }; Connection();
Connection( int socket ) { this->socket = socket; }; Connection( int socket );
virtual ~Connection(); virtual ~Connection();
virtual int InitiateServer( unsigned short port ); virtual int InitiateServer( unsigned short port );
@ -39,6 +39,9 @@ namespace Oyster
int socket; int socket;
bool stillSending;
bool closed;
}; };
} }
} }

View File

@ -120,7 +120,7 @@ void PrintOutMessage(ProtocolSet* set)
break; break;
case PackageType_player_pos: case PackageType_player_pos:
cout << "ID " << set->Protocol.pPlayerPos->ID << endl; //cout << "ID " << set->Protocol.pPlayerPos->ID << endl;
for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++) for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++)
{ {
cout << set->Protocol.pPlayerPos->matrix[i] << ' '; cout << set->Protocol.pPlayerPos->matrix[i] << ' ';