mirror of
https://github.com/statbate/fantastic-engine.git
synced 2026-08-11 03:02:41 +00:00
update
This commit is contained in:
parent
307e90a46e
commit
8f4ed6757f
2 changed files with 55 additions and 0 deletions
25
test/enter.py
Normal file
25
test/enter.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests, json, websocket
|
||||
|
||||
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbF9jb25maXJtZWQiOmZhbHNlLCJnZW5kZXIiOiJnIiwiaGFzX2NjIjpmYWxzZSwiaGFzX3B1cmNoYXNlIjpmYWxzZSwiaGFzX3Rva2VucyI6ZmFsc2UsImhpZGVfdmlwX2JhZGdlIjpmYWxzZSwiaWF0IjoxNjg3NTI5OTMyLCJpc19ndWVzdCI6dHJ1ZSwiaXNfbW9kZWwiOmZhbHNlLCJpc19tb2RlbF9hZG1pbiI6ZmFsc2UsImlzX3NpdGVfbW9kIjpmYWxzZSwiaXNfc3VwZXJfdmlwIjpmYWxzZSwiaXNfdmlwIjpmYWxzZSwiaXNfYm90IjpmYWxzZSwiaXNzIjoiaHR0cDpcL1wvY2Ftc29kYS5jb20iLCJyZWNlbnRfcHVyY2hhc2VzIjpmYWxzZSwidG9rZW5zIjowLCJ1c2VybmFtZSI6Imd1ZXN0XzM2MTk0In0.Ono1bECiI5rQEVUNzeEZ-ISU6Nb5u2-JIe47iZbrzhU"
|
||||
|
||||
def on_open(ws):
|
||||
welcome = json.dumps(["v3.authorize", {"token": token}])
|
||||
ws.send(welcome)
|
||||
print(welcome)
|
||||
|
||||
def on_message(ws, message):
|
||||
print("Received message: {}".format(message))
|
||||
|
||||
|
||||
def on_error(ws, error):
|
||||
print("Error encountered: {}".format(error))
|
||||
|
||||
def on_close(ws, b, c):
|
||||
print(ws, b, c)
|
||||
print("WebSocket connection closed.")
|
||||
|
||||
|
||||
ws = websocket.WebSocketApp("wss://node2-ord.livemediahost.com:5870", on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close)
|
||||
ws.run_forever()
|
||||
30
test/test.py
Normal file
30
test/test.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests, json, websocket
|
||||
|
||||
def on_open(ws):
|
||||
r = requests.get("https://www.camsoda.com/api/v1/user/current")
|
||||
dist = json.loads(r.text)
|
||||
welcome = json.dumps(["v3.authorize", {"token": dist["user"]["node_token"]}])
|
||||
ws.send(welcome)
|
||||
print(welcome)
|
||||
|
||||
def on_message(ws, message):
|
||||
print("Received message: {}".format(message))
|
||||
dist = json.loads(message)
|
||||
print(dist[0])
|
||||
if dist[0] == 2:
|
||||
join = json.dumps([5, {"room": "irisallen"}])
|
||||
ws.send(join)
|
||||
print(join)
|
||||
|
||||
def on_error(ws, error):
|
||||
print("Error encountered: {}".format(error))
|
||||
|
||||
def on_close(ws, b, c):
|
||||
print(ws, b, c)
|
||||
print("WebSocket connection closed.")
|
||||
|
||||
|
||||
ws = websocket.WebSocketApp("wss://node2-ord.livemediahost.com:3000", on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close)
|
||||
ws.run_forever()
|
||||
Loading…
Add table
Add a link
Reference in a new issue