Hi,
I don't keep track of stack overflow so I don't know if anybody else would answer stuff there.
Secondly, I replied to a very similar question you asked on this list last week - is this the same problem as that?
Andrew
On Mon, Sep 4, 2017 at 1:45 AM, Samuel Muiruri <muiruri.samuel@gmail.com> wrote:
--According to django-channels' github any "help" related issue should be posted here, I've asked this question before here and on stack with no response, don't feel the need to but if I don't get an adequate response I might need to hire a dev to implement this for me.I have this code for a socket connectionsocket = new WebSocket("ws://" + window.location.host + "/chat/");socket.onmessage = function(response) {console.log(response.data);}socket.onopen = function() {socket.send({"test":"data"});}// Call onopen directly if socket is already openif (socket.readyState == WebSocket.OPEN) socket.onopen();works nicely and connects to this route (even though it's supposed to look for /chat/ but I can work on setting this later)from gallery.consumers import ws_connect, ws_messagechannel_routing = [# Wire up websocket channels to our consumers:route("websocket.connect", ws_connect),route("websocket.receive", ws_message),]and in the consumers fileimport jsonfrom channels import Groupfrom channels.sessions import channel_session# Connected to websocket.connect@channel_sessiondef ws_connect(message, key):# Accept connectionmessage.reply_channel.send({"accept": True}) # Connected to websocket.receive@channel_sessiondef ws_message(message, key):reply = json.dumps({'status':'ok'})message.reply_channel.send({"text": reply}) # Connected to websocket.disconnect@channel_sessiondef ws_disconnect(message, key):message.reply_channel.send({'accept': False}) first hurdle I need to get over is getting the data sent via sockets i.e.socket.onopen = function() {socket.send({"test":"data"});}then I can move to having this trigger a background process so I can send the status and finally the final result via sockets.--Best Regards,Samuel Muiruri.Web Designer| +254 738 940064
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ .CAJZFZXoiq3WQ5zaXGMSxYpAfCREqQ tC-73yTL8-9OED9vA0m4Q%40mail. gmail.com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1urLEz5B6Zqzj-RuL%2BpS3LD00J-eD_XBhPM7U34xjz_VCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment