aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/he/moonbase/net_defines.h2
-rw-r--r--engines/scumm/he/moonbase/net_main.cpp38
-rw-r--r--engines/scumm/he/moonbase/net_main.h4
3 files changed, 40 insertions, 4 deletions
diff --git a/engines/scumm/he/moonbase/net_defines.h b/engines/scumm/he/moonbase/net_defines.h
index 79d1651f58..2e466d69f2 100644
--- a/engines/scumm/he/moonbase/net_defines.h
+++ b/engines/scumm/he/moonbase/net_defines.h
@@ -59,7 +59,7 @@ const int MAX_HOSTNAME_SIZE = 256;
const int MAX_IP_SIZE = 32;
const char LOCAL_HOST[] = "127.0.0.1"; //localhost
-const int DATA_HEADER_SIZE = 24;
+const int DATA_HEADER_SIZE = 28;
#define NULL_IP ""; //no IP address (causes enumsessions to search local subnet)
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index bb371ff75b..42e475075d 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -340,6 +340,7 @@ int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, byte *data,
pack.writeUint32LE(_myUserId);
pack.writeUint32LE(typeOfSend);
pack.writeUint32LE(sendTypeParam);
+ pack.writeUint32LE(type);
pack.writeUint32LE(len);
pack.writeUint32LE(g_system->getMillis());
pack.write(data, len);
@@ -453,16 +454,32 @@ int Net::getMessageCount() {
}
void Net::remoteReceiveData() {
- // FIXME. Get data into _packbuffer
+ Networking::PostRequest rq(_serverprefix + "/getpacket",
+ new Common::Callback<Net, Common::JSONValue *>(this, &Net::remoteReceiveDataCallback),
+ new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::remoteReceiveDataErrorCallback));
- int _packetsize = 0;
+ char *buf = (char *)malloc(MAX_PACKET_SIZE);
+ snprintf(buf, MAX_PACKET_SIZE, "{\"sessionid\":%d, \"userid\":%d}", _sessionid, _myUserId);
+ rq.setPostData((byte *)buf, strlen(buf));
+ rq.setContentType("application/json");
+
+ _packetsize = -1;
+ rq.start();
+
+ while(rq.state() == Networking::PROCESSING) {
+ g_system->delayMillis(5);
+ }
+
+ if (_packetsize == -1)
+ return;
Common::MemoryReadStream pack(_packbuffer, _packetsize);
pack.readUint32LE(); // sessionid
uint from = pack.readUint32LE();
- uint type = pack.readUint32LE(); // typeOfSend
+ pack.readUint32LE(); // typeOfSend
pack.readUint32LE(); // sendTypeParam
+ uint type = pack.readUint32LE();
uint len = pack.readUint32LE();
pack.readUint32LE(); // timestamp
@@ -529,6 +546,21 @@ void Net::remoteReceiveData() {
}
}
+void Net::remoteReceiveDataCallback(Common::JSONValue *response) {
+ debug(1, "remoteReceiveData: Got: '%s'", response->stringify().c_str());
+
+ if (!response->child("size")->asIntegerNumber())
+ return;
+
+ _packetsize = response->child("size")->asIntegerNumber();
+
+ strncpy((char *)_packbuffer, response->child("data")->asString().c_str(), _packetsize);
+}
+
+void Net::remoteReceiveDataErrorCallback(Networking::ErrorResponse error) {
+ warning("Error in remoteReceiveData(): %ld %s", error.httpResponseCode, error.response.c_str());
+}
+
void Net::unpackageArray(int arrayId, byte *data, int len) {
warning("STUB: unpackageArray");
}
diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h
index 74fc021d82..0f6d547754 100644
--- a/engines/scumm/he/moonbase/net_main.h
+++ b/engines/scumm/he/moonbase/net_main.h
@@ -83,6 +83,9 @@ private:
void remoteSendDataCallback(Common::JSONValue *response);
void remoteSendDataErrorCallback(Networking::ErrorResponse error);
+ void remoteReceiveDataCallback(Common::JSONValue *response);
+ void remoteReceiveDataErrorCallback(Networking::ErrorResponse error);
+
public:
//getters
bool getHostName(char *hostname, int length);
@@ -102,6 +105,7 @@ public:
ScummEngine_v100he *_vm;
byte *_packbuffer;
+ int _packetsize;
byte *_tmpbuffer;
int _myUserId;