Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

html set name chatapp

const room = 'waiting';
      const socket = io('/tech');
      $('form').submit(() => {
        let msg = $('#m').val();
        socket.emit('message', { msg, room });
        $('#m').val('');
        return false;
      });

      socket.on('connect', () => {
        // emiting to everybody
        socket.emit('join', { room: room });
      })

      socket.on('message', (msg) => {
        $('#messages').append($('<li>').text(name + msg));
      })
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #html #set #chatapp
ADD COMMENT
Topic
Name
5+4 =