Browse Source

Simple HttpRequest example

Josh Engebretson 10 years ago
parent
commit
2e5aeb9ead

+ 9 - 0
HttpRequestExample/HttpRequestExample.atomic

@@ -0,0 +1,9 @@
+{
+   "version": 1,
+   "project": {
+      "version": "1.0.0"
+   },
+   "platforms": [
+      "mac", "windows"
+   ]
+}

+ 20 - 0
HttpRequestExample/Resources/Scripts/main.js

@@ -0,0 +1,20 @@
+
+
+// get the network subsystem
+var network = Atomic.getNetwork();
+
+// non blocking http request runs on it's own thread
+var request = network.makeHttpRequest("http://www.google.com");
+
+// listen in to engine update
+network.subscribeToEvent("Update", function () {
+
+	if (request.state == Atomic.HTTP_CLOSED) {
+
+		 print(request.read());
+
+		 Atomic.getEngine().exit();
+
+		}
+
+});

BIN
HttpRequestExample/Resources/Sprites/star.png