|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en-US"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 6 | + <title>weapp.socket.io | weapp.socket.io</title> |
| 7 | + <meta name="description" content="Write your awesome realtime Wechat mini program"> |
| 8 | + <link rel="icon" href="/logo.png"> |
| 9 | + <link rel="manifest" href="/manifest.json"> |
| 10 | + <meta name="theme-color" content="#3eaf7c"> |
| 11 | + <meta name="apple-mobile-web-app-capable" content="yes"> |
| 12 | + <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
| 13 | + <link rel="apple-touch-icon" href="/logo.png"> |
| 14 | + <meta name="msapplication-TileColor" content="#000000"> |
| 15 | + |
| 16 | + <link rel="preload" href="/assets/css/3.styles.8c6ad8ec.css" as="style"><link rel="preload" href="/assets/js/app.8d62ecf8.js" as="script"><link rel="preload" href="/assets/js/0.e92912bb.js" as="script"><link rel="prefetch" href="/assets/js/1.ee1ccf7d.js"><link rel="prefetch" href="/assets/js/2.56adbf7b.js"> |
| 17 | + <link rel="stylesheet" href="/assets/css/3.styles.8c6ad8ec.css"> |
| 18 | + </head> |
| 19 | + <body> |
| 20 | + <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div><a href="/" class="home-link router-link-active"><!----><span class="site-name"> |
| 21 | + weapp.socket.io |
| 22 | + </span></a><div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""><!----></div><nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">Home</a></div><div class="nav-item"><a href="/demo/" class="nav-link">Demo</a></div><div class="nav-item"><a href="/guide/" class="nav-link router-link-exact-active router-link-active">Guide</a></div><a href="https://github.com/weapp-socketio/weapp.socket.io" target="_blank" rel="noopener noreferrer" class="github-link"> |
| 23 | + GitHub |
| 24 | + <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header><div class="sidebar-mask"></div><div class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">Home</a></div><div class="nav-item"><a href="/demo/" class="nav-link">Demo</a></div><div class="nav-item"><a href="/guide/" class="nav-link router-link-exact-active router-link-active">Guide</a></div><a href="https://github.com/weapp-socketio/weapp.socket.io" target="_blank" rel="noopener noreferrer" class="github-link"> |
| 25 | + GitHub |
| 26 | + <svg xmlns=" http://www.w3.org/2000/svg" aria-hidden=" true" x=" 0px" y=" 0px" viewBox=" 0 0 100 100" width=" 15" height=" 15" class=" icon outbound" ><path fill=" currentColor" d=" M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" ></path><polygon fill=" currentColor" points=" 45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" ></polygon></svg></a></nav><!----></div><div class=" page" ><div class=" content" ><h1 id=" weapp-socket-io" ><a href=" #weapp-socket-io" aria-hidden=" true" class=" header-anchor" ># </a> weapp.socket.io </h1><p>See <a href=" https://github.com/wxsocketio/socket.io-weapp-demo" target=" _blank" rel=" noopener noreferrer" >Weapp demo </a></p><h2 id=" feature" ><a href=" #feature" aria-hidden=" true" class=" header-anchor" ># </a> Feature </h2><p>Full feature socket.io style implemented (polling & websocket), based-on <code>[email protected]</code> version </p><blockquote><p>Note: weapp's http request not support binary, so you can't transport binary data use polling. |
| 27 | +Not support multiple connection for now, please wait next version 😃</p></blockquote><h2 id="how-to-use"><a href="#how-to-use" aria-hidden="true" class="header-anchor">#</a> How to use</h2><h3 id="install"><a href="#install" aria-hidden="true" class="header-anchor">#</a> Install</h3><pre class="language-text"><code> npm i weapp.socket.io |
| 28 | +</code></pre><p>or</p><pre class="language-text"><code> git clone https://github.com/wxsocketio/weapp.socket.io.git |
| 29 | +</code></pre><h3 id="compiled"><a href="#compiled" aria-hidden="true" class="header-anchor">#</a> Compiled</h3><pre class="language-text"><code>npm run build-dev |
| 30 | +npm run build |
| 31 | +</code></pre><p>if you use <code>yarn</code></p><pre class="language-text"><code>yarn build-dev |
| 32 | +yarn build |
| 33 | +</code></pre><h3 id="import-yout-weapp-project"><a href="#import-yout-weapp-project" aria-hidden="true" class="header-anchor">#</a> Import yout weapp project</h3><ol><li>move your compiled file in your <code>dist</code> dir</li><li>require this filr in your code.</li></ol><h3 id="example-code"><a href="#example-code" aria-hidden="true" class="header-anchor">#</a> example code</h3><p>code style is same to <a href="https://github.com/socketio/socket.io-client" target="_blank" rel="noopener noreferrer">socket.io-client</a></p><pre class="language-text"><code>const io = require('./yout_path/weapp.socket.io.js') |
| 34 | + |
| 35 | +const socket = io('http://localhost:8000') |
| 36 | + |
| 37 | +socket.on('news', d => { |
| 38 | + console.log('received news: ', d) |
| 39 | +}) |
| 40 | + |
| 41 | +socket.emit('news', { |
| 42 | + title: 'this is a news' |
| 43 | +}) |
| 44 | +</code></pre><h1 id="api"><a href="#api" aria-hidden="true" class="header-anchor">#</a> API</h1><p>See <a href="https://github.com/socketio/socket.io-client/blob/master/docs/API.md" target="_blank" rel="noopener noreferrer">socket.io-client API</a></p></div><!----><!----></div></div></div> |
| 45 | + <script src="/assets/js/0.e92912bb.js" defer></script><script src="/assets/js/app.8d62ecf8.js" defer></script> |
| 46 | + </body> |
| 47 | +</html> |
0 commit comments