Merge branch 'Network' of https://github.com/dean11/Danbias into Network

Conflicts:
	Code/Network/NetworkDependencies/Connection.cpp
	Code/Network/NetworkDependencies/Connection.h
	Code/Network/OysterNetworkClient/ClientMain.cpp
	Code/Network/OysterNetworkServer/ServerMain.cpp
This commit is contained in:
Pontus Fransson 2013-11-22 09:24:44 +01:00
commit bacb83b084
4 changed files with 3 additions and 43 deletions

View File

@ -98,13 +98,10 @@ bool Connection::Send(const unsigned char message[])
{ {
int nBytes; int nBytes;
unsigned long messageSize = strlen((char*)message); unsigned long messageSize = strlen((char*)message);
<<<<<<< HEAD
if((nBytes = send(mySocket, (char*)message , messageSize, 0)) == SOCKET_ERROR)
=======
messageSize = 18; messageSize = 18;
nBytes = send(mySocket, (char*)message , messageSize, 0); nBytes = send(mySocket, (char*)message , messageSize, 0);
if(nBytes == SOCKET_ERROR) if(nBytes == SOCKET_ERROR)
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
{ {
//Send failed! //Send failed!
return false; return false;

View File

@ -23,15 +23,10 @@ namespace Oyster
virtual bool InitiateServer( unsigned short port ); virtual bool InitiateServer( unsigned short port );
virtual void Disconnect(); virtual void Disconnect();
<<<<<<< HEAD
virtual bool Send(const unsigned char message[]);
virtual int Recieve(char unsigned message[]);
=======
virtual bool Send(const unsigned char message[]); virtual bool Send(const unsigned char message[]);
virtual int Recieve(unsigned char message[]); virtual int Recieve(unsigned char message[]);
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
virtual int Listen(); virtual int Listen();
private: private:

View File

@ -31,15 +31,7 @@ int main()
//Connect to server //Connect to server
client.Connect(9876, "127.0.0.1"); client.Connect(9876, "127.0.0.1");
unsigned char* recvBuffer = new unsigned char[255];
<<<<<<< HEAD
client.Send(recvBuffer);
//chat(client);
=======
chat(client); chat(client);
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
//Recieve message //Recieve message
//client.Recv(msgRecv); //client.Recv(msgRecv);
@ -66,18 +58,13 @@ void ShutdownSockets()
void chat(Client client) void chat(Client client)
{ {
<<<<<<< HEAD
unsigned char msgRecv[255] = "\0";
unsigned char msgSend[255] = "\0";
=======
Oyster::Network::Translator *t = new Oyster::Network::Translator(); Oyster::Network::Translator *t = new Oyster::Network::Translator();
unsigned char msgRecv[255] = "\0"; unsigned char msgRecv[255] = "\0";
string msgSend = ""; string msgSend = "";
ProtocolHeader header; ProtocolHeader* header;
ProtocolTest test; ProtocolTest test;
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
bool chatDone = false; bool chatDone = false;
@ -87,30 +74,16 @@ void chat(Client client)
header = t->Translate(msgRecv); header = t->Translate(msgRecv);
switch(header.packageType) switch(header->packageType)
{ {
case package_type_header: case package_type_header:
break; break;
case package_type_test: case package_type_test:
cout <<"Client 2: " <<((ProtocolTest*)&header)->textMessage <<endl; cout <<"Client 2: " <<((ProtocolTest*)&header)->textMessage <<endl;
break; break;
} }
<<<<<<< HEAD
cin.getline((char*)msgSend , 255 , '\n');
if(strlen((char*)msgSend) < 1)
{
memcpy(msgSend, " ", 1);
}
if((char*)msgSend != "exit")
{
if(strlen((char*)msgSend) < 1)
{
memcpy(msgSend, "ERROR", 1);
=======
std::getline(std::cin, msgSend); std::getline(std::cin, msgSend);
std::cin.clear(); std::cin.clear();
@ -128,7 +101,6 @@ void chat(Client client)
//memcpy(msgSend, "ERROR" , 5); //memcpy(msgSend, "ERROR" , 5);
msgSend = "ERROR!"; msgSend = "ERROR!";
//strcpy_s(msgSend, "ERROR"); //strcpy_s(msgSend, "ERROR");
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
} }
test.packageType = package_type_test; test.packageType = package_type_test;

View File

@ -40,12 +40,8 @@ int main()
Client client2(clientSocket); Client client2(clientSocket);
cout << "Second client connected." << endl; cout << "Second client connected." << endl;
<<<<<<< HEAD
client1.Send((unsigned char*)"Hej"); client1.Send((unsigned char*)"Hej");
ProtocolHeader* header = NULL; ProtocolHeader* header = NULL;
=======
client1.Send((unsigned char*) "Hej");
>>>>>>> 4142688f6c4a63aa97341205588ad6cace0f43af
while(1) while(1)
{ {