2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-08-20 01:14:03 -04:00
|
|
|
|
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"
|