/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2018 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include
#include
#include
struct SocketPunchInfo {
int runnerId;
int iHashType; // Hash including contolId, courseControlId (duplicate info in course), race number
int status;
int time;
SocketPunchInfo() {
runnerId = -1;
iHashType = -1;
status = -1;
time = -1;
}
};
class DirectSocket {
private:
struct ExtPunchInfo {
int cmpId;
SocketPunchInfo punch;
};
int competitionId;
list messageQueue;
HWND hDestinationWindow;
CRITICAL_SECTION syncObj;
volatile bool shutDown;
void listenDirectSocket();
void addPunchInfo(const SocketPunchInfo &pi);
bool startedUDPThread;
SOCKET sendSocket;
bool clearQueue;
int port;
public:
void startUDPSocketThread(HWND targetWindow);
void sendPunchInfo(SocketPunchInfo &pi);
void getPunchQueue(vector &queue);
void sendPunch(SocketPunchInfo &pi);
DirectSocket(int cmpId, int port);
~DirectSocket();
friend void startListeningDirectSocket(void *p);
};