ADD: added websocket and offline version an dtracklist
This commit is contained in:
@@ -3,11 +3,17 @@
|
||||
|
||||
#include "DirectCommunicationClient.hpp"
|
||||
#include "DirectCommunicationServer.hpp"
|
||||
#include "SimControl/Tracklist.hpp"
|
||||
#include "SimCore/Identifier.hpp"
|
||||
#include "WHISPER/InternalUDPListener.hpp"
|
||||
#include "crossguid/guid.hpp"
|
||||
#include "ixwebsocket/IXConnectionState.h"
|
||||
#include "ixwebsocket/IXWebSocketMessage.h"
|
||||
#include "ixwebsocket/IXWebSocketServer.h"
|
||||
#include "kubecontrol/PodController.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#include <ixwebsocket/IXWebSocket.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
@@ -27,35 +33,52 @@ namespace SimControl {
|
||||
class SimControl{
|
||||
|
||||
public:
|
||||
SimControl(std::string CommandPort);
|
||||
SimControl(bool online, std::string CommandPort,std::string GroundTruthAddr = "239.0.0.1", ushort GroundTruthPort = 10000, std::string Namespace = "simulator");
|
||||
~SimControl();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
|
||||
bool online_;
|
||||
|
||||
const SimCore::Identifier ID_;
|
||||
std::string CommandPort_;
|
||||
|
||||
std::string GroundTruthAddr_;
|
||||
ushort GroundTruthPort_;
|
||||
std::string Namespace_;
|
||||
|
||||
void MainFunction_();
|
||||
|
||||
void HandleMessage(std::string msg);
|
||||
|
||||
void HandleExternalMessage(std::string msg);
|
||||
void HandleTCPMessage(std::string msg);
|
||||
|
||||
|
||||
void startShip(std::string name);
|
||||
|
||||
void startWebApp();
|
||||
|
||||
std::unique_ptr<kubecontrol::PodController> PodController_;
|
||||
|
||||
std::unique_ptr<TrackList> Tracklist_;
|
||||
|
||||
std::thread MainThread_;
|
||||
std::atomic<bool> stopMainThread_ = false;
|
||||
|
||||
std::shared_ptr<DirectCommunication::DirectCommunicationClient> TCPClient_ = nullptr;
|
||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> ExternalTCPServer_ = nullptr;
|
||||
std::shared_ptr<DirectCommunication::DirectCommunicationServer> ExternalTCPServer_ = nullptr;
|
||||
|
||||
|
||||
|
||||
std::thread WebsocketThreadThread_;
|
||||
std::atomic<bool> stopWebsocketThreadThread_ = false;
|
||||
int port = 9999;
|
||||
std::string host = "0.0.0.0";
|
||||
std::shared_ptr<ix::WebSocketServer> WebsocketServer_ = nullptr;
|
||||
void startWebsocketServer();
|
||||
void HandleWebsocketMessages(std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket &websocket, const ix::WebSocketMessagePtr &msg);
|
||||
|
||||
std::shared_ptr<WHISPER::InternalUDPListener> BroadcastListener_;
|
||||
void HandleBroadcastMessage(std::string msg);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
32
include/SimControl/Tracklist.hpp
Normal file
32
include/SimControl/Tracklist.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include <SimCore/Identifier.hpp>
|
||||
#include <SimCore/Messages/SimTrack.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace SimControl
|
||||
{
|
||||
class TrackList
|
||||
{
|
||||
public:
|
||||
TrackList();
|
||||
void addTrack(std::shared_ptr<SimCore::SimTrack> Track);
|
||||
std::shared_ptr<SimCore::SimTrack> getTrack(SimCore::Identifier);
|
||||
|
||||
void getJsonTRackList(nlohmann::json &message);
|
||||
|
||||
|
||||
private:
|
||||
mutable std::mutex mx_;
|
||||
std::map<std::string, std::shared_ptr<SimCore::SimTrack>> TrackStore_;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user