SHARE
TWEET

Untitled

a guest Feb 27th, 2020 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <title>Koa-Socket Example</title>
  6.   <meta name="viewport" content="width=device-width, initial-scale=1">
  7.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8.   <style>
  9.     body {
  10.       margin: 0;
  11.       padding: 20px;
  12.       -webkit-font-smoothing: antialiased;
  13.       -moz-osx-font-smoothing: grayscale;
  14.       font-family: -apple-system, '.SFNSDisplay-Regular', 'Helvetica Neue', 'Arial', sans-serif;
  15.       color: #32322C;
  16.     }
  17.  
  18.     button {
  19.       display: block;
  20.       margin-top: .5em;
  21.       border: none;
  22.       border-radius: 4px;
  23.       font-size: 18px;
  24.       font-weight: 600;
  25.       text-align: center;
  26.       padding: .3em 3em;
  27.       background: #13C4A3;
  28.       transition: all .177s linear;
  29.       text-decoration: none;
  30.       cursor: pointer;
  31.     }
  32.     button:hover {
  33.       background: #36F1CD;
  34.       text-shadow: 0px 1px 2px rgba( 0, 0, 0, .3 );
  35.     }
  36.     .small {
  37.       font-size: 70%;
  38.     }
  39.  
  40.     .connections {
  41.       position: absolute;
  42.       width: 44px;
  43.       height: 44px;
  44.       top: 20px;
  45.       right: 20px;
  46.       line-height: 44px;
  47.       font-size: 16px;
  48.       font-weight: 700;
  49.       background: rgba( 0, 0, 0, .45 );
  50.       color: white;
  51.       border-radius: 4px;
  52.     }
  53.     .connections span {
  54.       display: block;
  55.       text-align: center;
  56.     }
  57.   </style>
  58. </head>
  59. <body>
  60.   <button class="js-chatBtn">Chat</button>
  61.   <div class="connections"><span class="js-connect">1</span></div>
  62.   <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.2/socket.io.slim.js"></script>
  63.   <script>
  64.  
  65.     var chat = io.connect( 'http://localhost:3000/chat', { query: "client_id=1&token=consultant_1" } );
  66.     chat.on( 'message', function( event ) {
  67.       alert("asdfadf");
  68.       console.log( 'chat message:', event );
  69.     });
  70.     var chatBtn = document.querySelector( '.js-chatBtn' );
  71.     chatBtn.addEventListener( 'click', function( event ) {
  72.       chat.emit( 'message', {'text': "123123", "image": 1} );
  73.     });
  74.   </script>
  75. </body>
  76. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top