2013-11-18 16:47:57 +01:00
|
|
|
#include <iostream>
|
2013-11-28 16:15:28 +01:00
|
|
|
#include <vector>
|
2013-11-22 14:23:08 +01:00
|
|
|
#include <vld.h>
|
2013-12-17 08:45:47 +01:00
|
|
|
#include <mutex>
|
2013-11-25 20:27:23 +01:00
|
|
|
#include "../NetworkDependencies/WinsockFunctions.h"
|
2013-12-16 08:59:38 +01:00
|
|
|
#include "../NetworkAPI/NetworkServer.h"
|
2013-12-17 09:05:32 +01:00
|
|
|
#include "../NetworkAPI/CustomNetProtocol.h"
|
|
|
|
#include "../NetworkAPI/NetworkCallbackHelper.h"
|
2013-11-19 13:42:50 +01:00
|
|
|
|
2013-12-16 08:59:38 +01:00
|
|
|
using namespace Oyster::Network;
|
2013-11-25 20:27:23 +01:00
|
|
|
using namespace std;
|
2013-11-21 13:42:38 +01:00
|
|
|
|
2013-12-17 08:45:47 +01:00
|
|
|
std::mutex m;
|
2013-12-17 09:05:32 +01:00
|
|
|
vector<NetworkClient> clients;
|
2013-12-17 08:45:47 +01:00
|
|
|
|
2013-12-16 08:59:38 +01:00
|
|
|
void proc(NetworkClient client)
|
|
|
|
{
|
|
|
|
cout << "Hej" << endl;
|
2013-12-17 08:45:47 +01:00
|
|
|
m.lock();
|
|
|
|
clients.push_back(client);
|
|
|
|
m.unlock();
|
2013-12-16 08:59:38 +01:00
|
|
|
}
|
|
|
|
|
2013-11-18 16:34:50 +01:00
|
|
|
int main()
|
2013-12-06 10:45:53 +01:00
|
|
|
{
|
2013-12-16 11:04:00 +01:00
|
|
|
SetDllDirectory("..\\DLL\\");
|
|
|
|
|
2013-12-16 08:59:38 +01:00
|
|
|
NetworkServer server;
|
|
|
|
Oyster::Network::NetworkServer::INIT_DESC desc;
|
|
|
|
desc.port = 15151;
|
|
|
|
desc.callbackType = NetworkClientCallbackType_Function;
|
2013-12-18 00:15:21 +01:00
|
|
|
//desc.recvObj = proc;
|
2013-12-16 08:59:38 +01:00
|
|
|
|
|
|
|
if(!server.Init(desc))
|
|
|
|
{
|
|
|
|
cout << "Init failed" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!server.Start())
|
2013-11-19 13:42:50 +01:00
|
|
|
{
|
2013-12-16 08:59:38 +01:00
|
|
|
cout << "Start failed" << endl;
|
|
|
|
return 0;
|
2013-11-19 13:42:50 +01:00
|
|
|
}
|
2013-12-09 22:22:05 +01:00
|
|
|
|
2013-12-16 08:59:38 +01:00
|
|
|
cout << "Server started" << endl;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2013-12-17 08:45:47 +01:00
|
|
|
Sleep(1000);
|
|
|
|
m.lock();
|
|
|
|
cout << clients.size() << endl;
|
|
|
|
m.unlock();
|
2013-12-16 08:59:38 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 08:45:47 +01:00
|
|
|
server.Stop();
|
2013-12-16 08:59:38 +01:00
|
|
|
|
2013-12-03 23:12:48 +01:00
|
|
|
system("pause");
|
2013-11-22 15:48:49 +01:00
|
|
|
|
2013-12-03 23:12:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|