foxygit / GZDoom Log in
commits tags

/src/net/webjoin/wj_server.h · 886 B

raw
// wj_server.h -- embedded HTTP+WebSocket server that lets phones on the
// same LAN join as local players. See wj_input.h for the threading
// contract this and wj_ticcmd.cpp (main thread) share.
#pragma once

#include <string>

// Starts listening on `port` (0 = pick the CVar-configured default).
// Generates a fresh random session token for this run, so a QR code
// scanned by someone not looking at the screen can't join. Safe to call
// again after WJ_StopServer(). Returns false if the port couldn't be
// bound.
bool WJ_StartServer(int port);

void WJ_StopServer();

bool WJ_IsServerRunning();

// http://<lan-ip>:<port>/?t=<token> for the currently running server, or
// empty if not running / no LAN address could be found. `ipIndex` selects
// among multiple detected local addresses (see wj_lanip.h).
std::string WJ_GetJoinURL(int ipIndex = 0);

int WJ_GetJoinURLCount();