2020-08-20 01:14:03 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2017-2020 FIRST. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2020-09-04 10:57:05 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
#include <hal/Extensions.h>
|
2020-08-20 01:14:03 -04:00
|
|
|
#include <wpi/raw_ostream.h>
|
|
|
|
|
|
|
|
|
|
#include "HALSimWSServer.h"
|
|
|
|
|
|
|
|
|
|
using namespace std::placeholders;
|
|
|
|
|
using namespace wpilibws;
|
|
|
|
|
|
2020-09-04 10:57:05 -07:00
|
|
|
static std::unique_ptr<HALSimWSServer> gServer;
|
2020-08-20 01:14:03 -04:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#if defined(WIN32) || defined(_WIN32)
|
|
|
|
|
__declspec(dllexport)
|
|
|
|
|
#endif
|
|
|
|
|
int HALSIM_InitExtension(void) {
|
2020-09-04 10:57:05 -07:00
|
|
|
wpi::outs() << "Websocket WS Server Initializing.\n";
|
|
|
|
|
|
|
|
|
|
HAL_OnShutdown(nullptr, [](void*) { gServer.reset(); });
|
2020-08-20 01:14:03 -04:00
|
|
|
|
2020-09-04 10:57:05 -07:00
|
|
|
gServer = std::make_unique<HALSimWSServer>();
|
|
|
|
|
if (!gServer->Initialize()) {
|
2020-08-20 01:14:03 -04:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-04 10:57:05 -07:00
|
|
|
wpi::outs() << "Websocket WS Server Initialized!\n";
|
2020-08-20 01:14:03 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
} // extern "C"
|