How use socketio decorator within another class
See original GitHub issueHi Miguel I tried to use socketio.Client within a class where i can call socketio and its related event frequently.But dnt understand how figure out it. It works fine on normal python file.
i m a part time coder,so plz dnt laugh on my coding. Thanks in advance.
import socketio
class warSock:
global mwar
global name
global ps
mwar = socketio.Client()
def __init__(self, name, ps):
self.name = name
self.ps = ps
@mwar.event
def connect(self):
print('connected to server')
@mwar.on('login')
def on_login(data):
print data
def connectme(self):
mwar.connect('http://localhost')
def dc(self):
mwar.disconnect()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
python - How to decorate class functions with flask-socketio if ...
Since decorating a function simply calls the decorator and passes the decorated function as the first argument you can write:
Read more >The Socket.IO Client — python-socketio documentation
To instantiate an Socket.IO client, simply create an instance of the appropriate client class: import socketio # standard Python sio = socketio.
Read more >python-socketio Documentation - Read the Docs
python-socketio Documentation. 2.10 Class-Based Namespaces. As an alternative to the decorator-based event handlers, the event handlers that belong to a ...
Read more >python-socketio Documentation - manpages.ubuntu!
This package contains two Socket.IO clients: • The socketio.Client() class creates a client compatible with the standard Python library. • The socketio.
Read more >How to manage users in socket.io in Node.js ? - GeeksforGeeks
js and express. Create two folders in your main directory name server(backend) and client(frontend). Socket.on will be an event that will be ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i know this is old but i wanted to have this kind of functionality and i have done this
This might be old and you have solved it. If you don’t need the self functionality in connect just make it static like this:
@staticmethod @mwar.event def connect(): print(‘connection established’)