0

I'm using Node.js with the express.js framework, and socket.IO. I have followed a couple of tutorials, and successfully web-sockets to work on Azure. It works, if I type in a message on one instance, it shows up on all the others as expected. But if i want to say, send a message from a python script and have it show up on the website, how do I go about doing this. Like, what "uri" do i use? Is it something like "wss://myAppService.azurewebsites.net"? I followed a couple of tutorials, and [this][1] question to get socket.io working using express. I am relatively new and inexperienced when it comes to node and websockets.
Here is my .pug view:

doctype html
head
  title Socket.IO chat
ul#messages
form#form(action='')
  input#input(autocomplete='off')
  button Send
  script(src="/socket.io/socket.io.js") 
  script. 
    var socket = io();

      var messages = document.getElementById('messages');
      var form = document.getElementById('form');
      var input = document.getElementById('input');

      form.addEventListener('submit', function(e) {
        e.preventDefault();
        if (input.value) {
          socket.emit('chat message', input.value);
          input.value = '';
        }
     });

     socket.on('chat message', function(msg) {
       var item = document.createElement('li');
        item.textContent = msg;
        messages.appendChild(item);
        window.scrollTo(0, document.body.scrollHeight);
     });

Any help is appreciated.
[1]: Using socket.io in Express 4 and express-generator's /bin/www

0 Answers0