📜  html 设置名称 chatapp - Html 代码示例

📅  最后修改于: 2022-03-11 14:53:30.834000             🧑  作者: Mango

代码示例1
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($('
  • ').text(name + msg)); })