diff options
author | Eugene Sandulenko | 2019-11-04 10:40:20 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-11-04 10:40:20 +0100 |
commit | e6b2615f340ca15fabdc8356bb879d29e0265cf8 (patch) | |
tree | 1a41895845b38b15abf5c5818c56d83e3ae02849 | |
parent | 2721dd2fef4169d8bba29051383f28b85022f55d (diff) | |
download | scummvm-rg350-e6b2615f340ca15fabdc8356bb879d29e0265cf8.tar.gz scummvm-rg350-e6b2615f340ca15fabdc8356bb879d29e0265cf8.tar.bz2 scummvm-rg350-e6b2615f340ca15fabdc8356bb879d29e0265cf8.zip |
SCUMM HE: MBC: Implement Net::endSession()
-rw-r--r-- | engines/scumm/he/moonbase/net_main.cpp | 31 | ||||
-rw-r--r-- | engines/scumm/he/moonbase/net_main.h | 3 |
2 files changed, 32 insertions, 2 deletions
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<Net, Common::JSONValue *>(this, &Net::endSessionCallback), + new Common::Callback<Net, Networking::ErrorResponse>(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 } diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h index aaa5b9a942..54b5496d28 100644 --- a/engines/scumm/he/moonbase/net_main.h +++ b/engines/scumm/he/moonbase/net_main.h @@ -78,6 +78,9 @@ private: void addUserCallback(Common::JSONValue *response); void addUserErrorCallback(Networking::ErrorResponse error); + void endSessionCallback(Common::JSONValue *response); + void endSessionErrorCallback(Networking::ErrorResponse error); + void remoteSendDataCallback(Common::JSONValue *response); void remoteSendDataErrorCallback(Networking::ErrorResponse error); |