summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js_bridge.js54
-rw-r--r--src/main.lua14
2 files changed, 26 insertions, 42 deletions
diff --git a/src/js_bridge.js b/src/js_bridge.js
index 2d32739..a9c8873 100644
--- a/src/js_bridge.js
+++ b/src/js_bridge.js
@@ -1,54 +1,24 @@
var s = document.createElement('script');
+var PEER = {};
s.setAttribute('src','https://unpkg.com/peerjs@1.5.2/dist/peerjs.min.js');
document.body.appendChild(s);
function genRanHex(size) {
return Array.apply(null,Array(size)).map(() => Math.floor(Math.random() * 16).toString(16)).join('');
}
-PEER = {}
-PEER.event_queue = {}
-PEER.peers = {}
-PEER.message_queue = {}
-PEER["create"] = function(name, options) {
- var peer = new Peer(name, options)
- PEER.peers[name] = peer
-}
+PEER.event_queue = {};
+PEER.peers = {};
+PEER.message_queue = {};
+PEER.create = function(name, options) {
+ var peer = new Peer(name, options);
+ PEER.peers[name] = peer;
+};
+/*
PEER["on"] = function(name, e, message) {
- PEER.peers[name].on(e, function(conn) {
- PEER.message_queue.push(message)
+ PEER.peers[name].on(e, function(data) {
+ PEER.message_queue.push({"message":message, "data":data})
}
}
PEER["connect"] = function(name, id, options) {
PEER.peers[name].connect(id, options)
}
-var peer = new Peer("ANGRY_ADVENTURE_" + GLOBAL.lobby_id, {"debug": 3});
-var peer_id = null;
-var poo = peer.on('open', function(id) {
- console.log('My peer ID is: ' + id);
- peer.on("connection",function(conn){
- console.log("Got a connection!")
- GLOBAL.connections[conn.peer] = conn
- conn.send("Hello!")
- GLOBAL.message_queue.push({
- "msg": "data",
- "peer": conn.peer,
- "data": '{"msg":"player_joined"}'
- })
- conn.on("data",function(data){
- console.log("Got some data from a peer!:" + data)
- GLOBAL.message_queue.push({
- "msg": "data",
- "peer": conn.peer,
- "data": data
- })
- })
- conn.on("error",function(err){
- console.log("Error on a connection:" + err)
- GLOBAL.message_queue.push({
- "msg": "error",
- "peer": conn.peer,
- "err": err
- })
- })
- })
- GLOBAL.peer_id = id;
-});
+*/
diff --git a/src/main.lua b/src/main.lua
index e69de29..176cddc 100644
--- a/src/main.lua
+++ b/src/main.lua
@@ -0,0 +1,14 @@
+
+print("Hello, world!")
+
+am.eval_js("console.log('Hello, js!')")
+
+local win = am.window{
+ title = "Hi",
+ width = 1280,
+ height = 720,
+ clear_color = vec4(0.8, 0.8, 0.3, 1)
+}
+print("about to pcall")
+local a,b = pcall(am.eval_js, require("js_bridge"))
+print("done with pcall", a,b)