Skip to content

Instantly share code, notes, and snippets.

@yosuke-furukawa
Created June 18, 2014 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosuke-furukawa/a8aff7bfdaa367f0f6fd to your computer and use it in GitHub Desktop.
Save yosuke-furukawa/a8aff7bfdaa367f0f6fd to your computer and use it in GitHub Desktop.
socket.io- websocket
<!DOCTYPE html>
<html>
<head>
<title>sample</title>
</head>
<body>
  <div id="Continar">
  </div>
    <script src="http://localhost:60001/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost:60001', {transports: ["websocket"]});
      socket.on('connect', function() {
        socket.emit("message","hay");
      });
      socket.on('reply', function(msg) {
        document.getElementById("Continar").innerHTML = msg;
      });
    </script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment