当前位置:   article > 正文

Python - SockeIO请求,模拟Web Socket 请求_python-socketio 重连

python-socketio 重连

Python - 模拟Web Socket 请求

Max.Bai
2017-04
 
有可能你找的是这个 套接字Socket Socket Client
 
需要用到socketio-client, logging

1. 安装SockeIO-Client

pip install socketio-client-2
 

2. 创建连接发送数据

  1. from socketIO_client import SocketIO
  2. hosts = 'http://websocke.server.com'
  3. port = 3000
  4. # 收到message消息处理过程
  5. def on_message(*args):
  6. # print "recv:", args
  7. # print "geted:", type(args[0])
  8. if type(args[0]) is types.DictType:
  9. rp = args[0]
  10. print "recv:", rp
  11. sk = SocketIO(hosts,port=port)
  12. sk = SocketIO(hosts,port=port,params={'token': 'ksdjfkjdf'}) #create connection with params
  13. # add lisenter for message response
  14. sk.on('me
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/172804
推荐阅读
相关标签
  

闽ICP备14008679号