Smooth connection and disconnection complete
The clients can connect and disconnect from the server with known no issues. There is no way to shutdown the server yet, but it might be possible to kick someone else from the server soon.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#include "defines.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
std::string itos(int i) {
|
||||
char buffer[20];
|
||||
snprintf(buffer, 20, "%d", i);
|
||||
return std::string(buffer);
|
||||
}
|
||||
@@ -2,10 +2,13 @@
|
||||
#define DEFINES_HPP
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
#define GAME_CHANNEL 0
|
||||
#define CHAT_CHANNEL 1
|
||||
|
||||
typedef std::chrono::high_resolution_clock Clock;
|
||||
|
||||
std::string itos(int i);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ static int networkQueue(void*) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BeginQueueThread() {
|
||||
void beginQueueThread() {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ void BeginQueueThread() {
|
||||
}
|
||||
}
|
||||
|
||||
void EndQueueThread() {
|
||||
void endQueueThread() {
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void EndQueueThread() {
|
||||
queueThread = nullptr;
|
||||
}
|
||||
|
||||
void KillQueueThread() {
|
||||
void killQueueThread() {
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
@@ -78,4 +78,12 @@ Packet popNetworkPacket() {
|
||||
}
|
||||
SDL_SemPost(lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
void flushNetworkQueue() {
|
||||
UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get();
|
||||
SDL_SemWait(lock);
|
||||
while(netUtil->Receive());
|
||||
queue.clear();
|
||||
SDL_SemPost(lock);
|
||||
}
|
||||
@@ -3,10 +3,11 @@
|
||||
|
||||
#include "packet_type.hpp"
|
||||
|
||||
void BeginQueueThread();
|
||||
void EndQueueThread();
|
||||
void KillQueueThread();
|
||||
void beginQueueThread();
|
||||
void endQueueThread();
|
||||
void killQueueThread();
|
||||
Packet peekNetworkPacket();
|
||||
Packet popNetworkPacket();
|
||||
void flushNetworkQueue();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -62,6 +62,7 @@ struct JoinResponse {
|
||||
|
||||
struct Disconnect {
|
||||
Metadata meta;
|
||||
int clientIndex;
|
||||
};
|
||||
|
||||
struct Synchronize {
|
||||
|
||||
Reference in New Issue
Block a user