/** * GET /leave/:join */ static void twitch_join() { char url[256]; sprintf(url, "%sjoin/%s", TwitchExtendedBaseUrl, gConfigTwitch.channel); _twitchState = TWITCH_STATE_JOINING; _twitchIdle = false; http_json_request request; request.url = url; request.method = HTTP_METHOD_GET; request.body = NULL; http_request_json_async(&request, [](http_json_response *jsonResponse) -> void { if (jsonResponse == NULL) { _twitchState = TWITCH_STATE_LEFT; console_writeline("Unable to connect to twitch channel."); } else { json_t *jsonStatus = json_object_get(jsonResponse->root, "status"); if (json_is_number(jsonStatus) && json_integer_value(jsonStatus) == 200) _twitchState = TWITCH_STATE_JOINED; else _twitchState = TWITCH_STATE_LEFT; http_request_json_dispose(jsonResponse); _twitchLastPulseTick = 0; console_writeline("Connected to twitch channel."); } _twitchIdle = true; }); }
void console_init() { _consoleInitialised = true; console_writeline(OPENRCT2_NAME " " OPENRCT2_VERSION); console_writeline(""); console_write_prompt(); }
/** * GET /leave/:channel */ static void twitch_leave() { if (_twitchJsonResponse != NULL) { http_request_json_dispose(_twitchJsonResponse); _twitchJsonResponse = NULL; } console_writeline("Left twitch channel."); _twitchState = TWITCH_STATE_LEFT; _twitchLastPulseTick = 0; gTwitchEnable = false; // TODO reset all peeps with twitch flag // HTTP request no longer used as it could be abused // char url[256]; // sprintf(url, "%sleave/%s", TwitchExtendedBaseUrl, gConfigTwitch.channel); // _twitchState = TWITCH_STATE_LEAVING; // _twitchIdle = false; // http_request_json_async(url, [](http_json_response *jsonResponse) -> void { // http_request_json_dispose(jsonResponse); // _twitchState = TWITCH_STATE_LEFT; // _twitchIdle = true; // // console_writeline("Left twitch channel."); // }); }
void console_printf(const char *format, ...) { va_list list; va_start(list, format); vsprintf(_consolePrintfBuffer, format, list); console_writeline(_consolePrintfBuffer); }
static int cc_echo(const char **argv, int argc) { if (argc > 0) console_writeline(argv[0]); return 0; }
void console_writeline_warning(const char *src) { strcpy(_consoleErrorBuffer + 1, src); _consoleErrorBuffer[0] = FORMAT_YELLOW; console_writeline(_consoleErrorBuffer); }
void console_writeline_error(const char *src) { strcpy(_consoleErrorBuffer + 1, src); _consoleErrorBuffer[0] = FORMAT_RED; console_writeline(_consoleErrorBuffer); }