Skip to content

Instantly share code, notes, and snippets.

@CRamsan
Created May 13, 2014 01:03
Show Gist options
  • Save CRamsan/a52b30dc14a20881f11f to your computer and use it in GitHub Desktop.
Save CRamsan/a52b30dc14a20881f11f to your computer and use it in GitHub Desktop.
import websocket
import thread
import time
import json
def on_message(ws, message):
print message
json.loads(request.read().decode('utf8'))
def on_error(ws, error):
print error
def on_close(ws):
print "### closed ###"
def on_open(ws):
def run(*args):
ws.send("{\"service\":\"event\",\"action\":\"subscribe\",\"worlds\":[\"1\",\"9\",\"10\",\"11\",\"13\",\"17\",\"18\",\"19\",\"25\"],\"eventNames\":[ \"MetagameEvent\" ]}")
thread.start_new_thread(run, ())
if __name__ == "__main__":
ws = websocket.WebSocketApp("wss://push.planetside2.com/streaming?service-id=s:PS2Link",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment