修改介绍
This commit is contained in:
parent
9ed064feac
commit
f8ddeb89a4
|
|
@ -4,6 +4,8 @@ const debug = require('debug')('@hyoga/uni-socket:')
|
|||
|
||||
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']
|
||||
|
||||
const nameSpace = uni || wx;
|
||||
|
||||
class WeappWebSocket extends EventEmitter {
|
||||
constructor(address, protocols, options) {
|
||||
super()
|
||||
|
|
@ -105,7 +107,7 @@ function initAsClient(address, protocols, options) {
|
|||
}
|
||||
|
||||
function createConnection(options) {
|
||||
const socketTask = uni.connectSocket({
|
||||
const socketTask = nameSpace.connectSocket({
|
||||
complete: ()=> {},
|
||||
...options,
|
||||
});
|
||||
|
|
@ -115,12 +117,12 @@ function createConnection(options) {
|
|||
}
|
||||
|
||||
return {
|
||||
onClose: uni.onSocketClose,
|
||||
onOpen: uni.onSocketOpen,
|
||||
onError: uni.onSocketError,
|
||||
onMessage: uni.onSocketMessage,
|
||||
send: uni.sendSocketMessage,
|
||||
close: uni.closeSocket,
|
||||
onClose: nameSpace.onSocketClose,
|
||||
onOpen: nameSpace.onSocketOpen,
|
||||
onError: nameSpace.onSocketError,
|
||||
onMessage: nameSpace.onSocketMessage,
|
||||
send: nameSpace.sendSocketMessage,
|
||||
close: nameSpace.closeSocket,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
32
package.json
32
package.json
|
|
@ -1,19 +1,24 @@
|
|||
{
|
||||
"name": "@hyoga/uni-socket",
|
||||
"version": "1.0.0",
|
||||
"description": "适用于uni-app的socket.io封装,可用于uni-app、微信小程序",
|
||||
"keywords": [
|
||||
"realtime",
|
||||
"framework",
|
||||
"mp-weixin",
|
||||
"uni-app",
|
||||
"websocket",
|
||||
"tcp",
|
||||
"events",
|
||||
"client"
|
||||
"socket.io",
|
||||
"微信小程序"
|
||||
],
|
||||
"main": "./dist/uni-socket.io.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"dist/"
|
||||
],
|
||||
"main": "./dist/uni-socket.io.js",
|
||||
"scripts": {
|
||||
"prepublish": "rm -rf ./dist && npm run build",
|
||||
"build-dev": "webpack --config webpack.config.dev.js",
|
||||
"build": "webpack --config webpack.config.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"socket.io-client": "^2.1.1"
|
||||
},
|
||||
|
|
@ -32,9 +37,14 @@
|
|||
"webpack-merge": "4.1.2",
|
||||
"webpack-stream": "3.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "rm -rf ./dist && npm run build",
|
||||
"build-dev": "webpack --config webpack.config.dev.js",
|
||||
"build": "webpack --config webpack.config.js"
|
||||
}
|
||||
"author": "lq9328@126.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+git@github.com:AspenLuoQiang/hyoga-uni-socket.io.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/AspenLuoQiang/hyoga-uni-socket.io/issues"
|
||||
},
|
||||
"homepage": "https://github.com/AspenLuoQiang/hyoga-uni-socket.io",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue