From e6b2615f340ca15fabdc8356bb879d29e0265cf8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 4 Nov 2019 10:40:20 +0100 Subject: SCUMM HE: MBC: Implement Net::endSession() --- engines/scumm/he/moonbase/net_main.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'engines/scumm/he/moonbase/net_main.cpp') diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp index a315c92154..303697b3f9 100644 --- a/engines/scumm/he/moonbase/net_main.cpp +++ b/engines/scumm/he/moonbase/net_main.cpp @@ -194,10 +194,37 @@ int Net::joinSession(int sessionIndex) { } int Net::endSession() { - warning("STUB: Net::endSession()"); // PN_EndSession - return 0; + debug(1, "Net::endSession()"); // PN_EndSession + + Networking::PostRequest rq(_serverprefix + "/endsession", + new Common::Callback(this, &Net::endSessionCallback), + new Common::Callback(this, &Net::endSessionErrorCallback)); + + char *buf = (char *)malloc(MAX_PACKET_SIZE); + snprintf(buf, MAX_PACKET_SIZE, "{\"sessionid\":%d}", _sessionid); + rq.setPostData((byte *)buf, strlen(buf)); + rq.setContentType("application/json"); + + rq.start(); + + while(rq.state() == Networking::PROCESSING) { + g_system->delayMillis(5); + } + + return _lastResult; +} + +void Net::endSessionCallback(Common::JSONValue *response) { + _lastResult = 1; } +void Net::endSessionErrorCallback(Networking::ErrorResponse error) { + warning("Error in endSession(): %ld %s", error.httpResponseCode, error.response.c_str()); + + _lastResult = 0; +} + + void Net::disableSessionJoining() { warning("STUB: Net::disableSessionJoining()"); // PN_DisableSessionPlayerJoin } -- cgit v1.2.3