Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Message Event #11

Open
bharat-gera opened this issue Oct 23, 2018 · 0 comments
Open

On Message Event #11

bharat-gera opened this issue Oct 23, 2018 · 0 comments

Comments

@bharat-gera
Copy link

bharat-gera commented Oct 23, 2018

I have number of websocket connections connected,what if I want to send message on that connection from using some function. Do we have any utility function in the library for the same?
I was trying to something like this:

import json
from .clients import WebsocketTestingClient
messageTypes = {
'handshake': 'hello',
'chan_register': 'register'
}
class WPushClient(WebsocketTestingClient):

def _construct_event_payload(self, request_type, **kwargs):
    data = dict()
    data['messageType'] = messageTypes[request_type]
    data.update(**kwargs)
    return json.dumps(data)

def _handshake_request(self):
    payload =  self._construct_event_payload('handshake', use_webpush=True)
    return payload

def after_connect(self, statedict):
    msg = self._handshake_request()
    self.logger.log(msg)
    statedict['connected_websocket'].ws.sendMessage(msg)

I was unable to send the "msg" on the websocket connection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant