umi-plugin-socket
v0.0.4-alpha.120
Published
模拟ws请求
Readme
socket-mock
模拟ws请求
Install
# or yarn
$ npm install$ npm run build --watch
$ npm run startUsage
Configure in .umirc.js,
//umi配置模拟ws服务
export default {
mockws: {
port: 3333,
watch: ['./database/index.ts']
}
}//客户端方法引用
import {ws} from 'umi'
ws.init(`socket地址`,`uid=${me.uid}`)
ws.on('msg',(data)=>{
console.log(data)
//the client witch uid==data.toUid will be send,it will show {type:'msg',data:'abc'}
})
ws.send({
type:'msg',
toUid:[to.uid],
data:'abc'
})Options
TODO
LICENSE
MIT
