2017-12-10 12:52:43 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2018-05-07 17:25:06 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from .vncoincheck import *
|
2017-12-10 12:52:43 +00:00
|
|
|
|
|
|
|
import socket
|
|
|
|
import json
|
|
|
|
import websocket
|
|
|
|
from websocket import create_connection
|
|
|
|
|
|
|
|
ws = None
|
|
|
|
def open():
|
|
|
|
global ws
|
2018-05-07 17:25:06 +00:00
|
|
|
print("open")
|
2017-12-10 12:52:43 +00:00
|
|
|
ws.send( json.dumps({"type": "subscribe", "channel": "btc_jpy-trades"}))
|
|
|
|
|
|
|
|
def testWebsocket():
|
|
|
|
global ws
|
|
|
|
|
|
|
|
while 1:
|
|
|
|
ws = create_connection("wss://ws-api.coincheck.com/", on_open=open)
|
|
|
|
if ws.connected:
|
|
|
|
|
2018-05-07 17:25:06 +00:00
|
|
|
print(ws.recv())
|
2017-12-10 12:52:43 +00:00
|
|
|
|
|
|
|
sleep(5)
|
|
|
|
|
|
|
|
# 阻塞
|
|
|
|
input()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
testWebsocket()
|