Network - Forgot to use Initiateclient().

This commit is contained in:
Pontus Fransson 2013-12-16 09:48:41 +01:00
parent 6f979b1044
commit 8a8cfcc5d6
6 changed files with 5 additions and 247 deletions

View File

@ -49,6 +49,7 @@ struct ClientDataContainer
callbackType = NetworkProtocolCallbackType_Unknown; callbackType = NetworkProtocolCallbackType_Unknown;
sendPostBox = new PostBox<CustomNetProtocol>(); sendPostBox = new PostBox<CustomNetProtocol>();
connection.SetBlockingMode(false); connection.SetBlockingMode(false);
connection.InitiateClient();
} }
ClientDataContainer(IThreadObject* o, unsigned int socket ) ClientDataContainer(IThreadObject* o, unsigned int socket )
:connection(socket), ID(currID++) :connection(socket), ID(currID++)
@ -56,6 +57,7 @@ struct ClientDataContainer
InitWinSock(); InitWinSock();
callbackType = NetworkProtocolCallbackType_Unknown; callbackType = NetworkProtocolCallbackType_Unknown;
sendPostBox = new PostBox<CustomNetProtocol>(); sendPostBox = new PostBox<CustomNetProtocol>();
connection.InitiateClient();
connection.SetBlockingMode(false); connection.SetBlockingMode(false);
} }
~ClientDataContainer() ~ClientDataContainer()

View File

@ -41,11 +41,12 @@ int main()
errorCode = client.Connect(15151, "127.0.0.1"); errorCode = client.Connect(15151, "127.0.0.1");
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
if(errorCode != 0) if(errorCode != 1)
{ {
printf("%d", errorCode);
cout << "FAILED" << endl; cout << "FAILED" << endl;
} }
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); //client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
cout << "Done" << endl; cout << "Done" << endl;

View File

@ -1,65 +0,0 @@
#include <iostream>
#include <WinSock2.h>
#include <vld.h>
#include "../NetworkDependencies/WinsockFunctions.h"
#include "..\NetworkDependencies\Protocols.h"
#include "../NetworkDependencies/OysterByte.h"
#include "../../Misc/ThreadSafeQueue.h"
#include "../NetworkDependencies/ThreadedClient.h"
#include "../../Misc/WinTimer.h"
#include "../../Misc/Utilities.h"
#include "../NetworkAPI/NetworkClient.h"
#pragma comment(lib, "ws2_32.lib")
using namespace std;
using namespace Oyster::Network::Protocols;
using namespace Oyster::Network;
using namespace Utility;
using namespace Utility::DynamicMemory;
void proc(CustomNetProtocol& protocol)
{
}
int main()
{
int errorCode;
char msgRecv[255] = "\0";
InitWinSock();
cout << "Client" << endl;
//Create Client
NetworkClient client;
//Connect to server
<<<<<<< HEAD
if(client.Connect(15151, "localhost"))
=======
//errorCode = client->Connect(15151, "193.11.186.101");
errorCode = client.Connect(15151, "127.0.0.1");
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
if(errorCode != 0)
>>>>>>> 9eb8fcba40e4dec4f338cd012ba69bc15d456cc9
{
cout << "FAILED" << endl;
}
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
cout << "Done" << endl;
while(1)
{
}
ShutdownWinSock();
system("pause");
return 0;
}

View File

@ -1,61 +0,0 @@
#include <iostream>
#include <WinSock2.h>
#include <vld.h>
#include "../NetworkDependencies/WinsockFunctions.h"
#include "..\NetworkDependencies\Protocols.h"
#include "../NetworkDependencies/OysterByte.h"
#include "../../Misc/ThreadSafeQueue.h"
#include "../NetworkDependencies/ThreadedClient.h"
#include "../../Misc/WinTimer.h"
#include "../../Misc/Utilities.h"
#include "../NetworkAPI/NetworkClient.h"
#pragma comment(lib, "ws2_32.lib")
using namespace std;
using namespace Oyster::Network::Protocols;
using namespace Oyster::Network;
using namespace Utility;
using namespace Utility::DynamicMemory;
void chat(ThreadedClient &client);
void PrintOutMessage(ProtocolSet* set);
void proc(CustomNetProtocol& protocol)
{
}
int main()
{
int errorCode;
char msgRecv[255] = "\0";
InitWinSock();
cout << "Client" << endl;
//Create Client
NetworkClient client;
//Connect to server
errorCode = client.Connect(15151, "193.11.186.101");
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
if(errorCode != 0)
{
wstring errorTest = GetErrorMessage(errorCode);
wcout << "errorMessage: " << errorTest << endl;
}
while(1)
{
}
ShutdownWinSock();
system("pause");
return 0;
}

View File

@ -1,57 +0,0 @@
#include <iostream>
#include <WinSock2.h>
#include <vld.h>
#include "../NetworkDependencies/WinsockFunctions.h"
#include "..\NetworkDependencies\Protocols.h"
#include "../NetworkDependencies/OysterByte.h"
#include "../../Misc/ThreadSafeQueue.h"
#include "../NetworkDependencies/ThreadedClient.h"
#include "../../Misc/WinTimer.h"
#include "../../Misc/Utilities.h"
#include "../NetworkAPI/NetworkClient.h"
#pragma comment(lib, "ws2_32.lib")
using namespace std;
using namespace Oyster::Network::Protocols;
using namespace Oyster::Network;
using namespace Utility;
using namespace Utility::DynamicMemory;
void proc(CustomNetProtocol& protocol)
{
}
int main()
{
int errorCode;
char msgRecv[255] = "\0";
InitWinSock();
cout << "Client" << endl;
//Create Client
NetworkClient client;
//Connect to server
if(client.Connect(15151, "localhost"))
{
cout << "FAILED" << endl;
}
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
cout << "Done" << endl;
while(1)
{
}
ShutdownWinSock();
system("pause");
return 0;
}

View File

@ -1,62 +0,0 @@
#include <iostream>
#include <WinSock2.h>
#include <vld.h>
#include "../NetworkDependencies/WinsockFunctions.h"
#include "..\NetworkDependencies\Protocols.h"
#include "../NetworkDependencies/OysterByte.h"
#include "../../Misc/ThreadSafeQueue.h"
#include "../NetworkDependencies/ThreadedClient.h"
#include "../../Misc/WinTimer.h"
#include "../../Misc/Utilities.h"
#include "../NetworkAPI/NetworkClient.h"
#pragma comment(lib, "ws2_32.lib")
using namespace std;
using namespace Oyster::Network::Protocols;
using namespace Oyster::Network;
using namespace Utility;
using namespace Utility::DynamicMemory;
void chat(ThreadedClient &client);
void PrintOutMessage(ProtocolSet* set);
void proc(CustomNetProtocol& protocol)
{
}
int main()
{
int errorCode;
char msgRecv[255] = "\0";
InitWinSock();
cout << "Client" << endl;
//Create Client
NetworkClient client;
//Connect to server
//errorCode = client->Connect(15151, "193.11.186.101");
errorCode = client.Connect(15151, "127.0.0.1");
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
if(errorCode != 0)
{
wstring errorTest = GetErrorMessage(errorCode);
wcout << "errorMessage: " << errorTest << endl;
}
while(1)
{
}
ShutdownWinSock();
system("pause");
return 0;
}