aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he/moonbase/net_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/he/moonbase/net_main.cpp')
-rw-r--r--engines/scumm/he/moonbase/net_main.cpp31
1 files changed, 29 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
}