Skip to content

jingshuixian/weapp.socket.io

 
 

Repository files navigation

logo

合作伙伴征集

如果你的项目正在使用 weapp.socket.io 欢迎留下你的项目信息(名称,Logo,官网等)

可以在 这个 Issue 提交您的项目信息

weapp.socket.io

See Weapp demo

Feature

Full feature socket.io style implemented, based-on socket.io@2.0 version

NOTE: Only support websocket transport, removed polling transport.

How to use

Install

If you use a third-party framework such as wepy, you should install via npm

  npm i weapp.socket.io

If you use the native way to write code,I recommend using git clone

  git clone https://github.com/wxsocketio/weapp.socket.io.git

Compiled

if you use npm you can skip this step

npm run build-dev
npm run build

if you use yarn

yarn build-dev
yarn build

Import yout weapp project

  1. move your compiled file in your dist dir
  2. require this filr in your code.

example code

code style is same to socket.io-client

const io = require('./yout_path/weapp.socket.io.js')

const socket = io('http://localhost:8000')

socket.on('news', d => {
  console.log('received news: ', d)
})

socket.emit('news', {
  title: 'this is a news'
})

API

See socket.io-client API

TODO

  • AliPay mini program

About

socket.io client for Wechat mini program

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%