[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Nightblade/EmmyLuaCodeStyle/master/CodeFormatServer/src/main.cpp [Back]  [Original]

#include "LanguageServer.h"
#include "Session/SocketIOSession.h"
#include "Session/StandardIOSession.h"
#include 
// https://stackoverflow.com/questions/1598985/c-read-binary-stdin
#ifdef _WIN32
#include 
#include 
#define SET_BINARY_MODE()                \
    _setmode(_fileno(stdin), _O_BINARY); \
    _setmode(_fileno(stdout), _O_BINARY)
#else
#define SET_BINARY_MODE() (void) 0
#endif

using namespace asio::ip;

int main(int argc, char **argv) {
    LanguageServer server;
    auto &ioc = server.GetIOContext();
    if (argc > 1) {
        int port = std::stoi(argv[1]);
        tcp::acceptor acceptor(ioc, tcp::endpoint(tcp::v4(), port));

        auto socket = acceptor.accept();
        server.SetSession(std::make_shared(std::move(socket)));
    } else {
        SET_BINARY_MODE();
        server.SetSession(std::make_shared());
    }

    return server.Run();
}

Web Proxy Viewer  |  New URL  |  Original Page