summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shop.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/shop.lua b/shop.lua
index a4ddfc3..0677c01 100644
--- a/shop.lua
+++ b/shop.lua
@@ -4,18 +4,30 @@ assert(sres.ok,"not ok")
ws = assert(http.websocket(sres.url))
nextid = 0
+our_addr = "???"
function sendws(t)
t.id = nextid
nextid = nextid + 1
return ws.send(textutils.serializeJSON(t))
end
-sendws {type="me"}
+
+function parsetrans()
while true do
msgtxt = assert(ws.receive(),"ws error")
msg = textutils.unserializeJSON(msgtxt)
if msg.type ~= "keepalive" then print(msgtxt) end
+ if msg.type == "response" and msg.responding_to_type == "me" then
+ our_addr = msg.address.address
+ local m = peripheral.wrap"left"
+ m.setCursorPos(1,1)
+ m.write(our_addr)
+ end
+ if msg.type == "event" and msg.event == "transaction" then
+ print("trans")
+
+ end
end