Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // <script src="/socket.io/socket.io.js"></script>
- // needs to be included in .html
- var socket = io();
- document.body.addEventListener('click', function() {
- // Hallo Welt is pushed to backend on body click
- socket.emit('sendMessage', "Hallo Welt");
- }, true);
- // Message is received from backend
- socket.on('getMessage', function(msg){
- console.log(msg);
- });
Add Comment
Please, Sign In to add comment