Skip to content

korando/socket-message

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket-message

Socket.IO server Used for transmit message between platforms

#usage

<script src="http://ip:port/socket.io/socket.io.js"></script>
<script>

    var socket = io('http://ip:port');
    socket.on('onRegister', function (data) {
      console.log("onRegister", data);
    });
    socket.on('onJoin', function (data) {
      console.log("onJoin", data);
    });
    socket.on('onJoinOther', function (data) {
      console.log("onJoinOther", data);
    });
    socket.on('onMessage', function (data) {
      console.log("onMessage", data);
    });

    $(function () {
      $('#cmdReg').click(function () {
        socket.emit('register');
      })
      $('#cmdJoin').click(function () {
        var groupName = $('#tbxRoom').val();
        socket.emit('join', groupName);
      })
      $('#cmdSend').click(function () {
        var o = { duration : 5};
        //send message as JSON
        socket.emit('message', o);
      })
    })
  </script>

About

socket use message p2p

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%