Speed up development with full-stack environments for every branch.

Learn More

Sending and receiving events with socket.io

2946 Runs 9750 Views 2136 Copies


sundip 66

published 5 years ago

    <style type="text/css">
      pre {background-color:rgba(0,0,0,0.2); padding:10px;}
    <script src="/socket.io/socket.io.js"></script>
    <script src="http://code.jquery.com/jquery.js"></script>
    $(function() {
      var socket = io.connect();
      var $pre = $('pre');
      socket.on('this', function (data) {
        $pre.text( $pre.text() + JSON.stringify(data) + '\n' );
        socket.emit('private message', 'Runnable', 'Hi!');
    <h1>socket.io example</h1>
    <pre>..output here..
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).