Comments (1)
@luo7023539 您好,感谢您使用并提出疑问。经过我的测试逗号的事情只是显示的问题,并不影响数据的解析。Server 端使用 socket.io 不需要任何特殊处理。一切正常请放心使用。
我的测试代码如下:
Codes
server.js
const chat = io.of('/chat').on('connection', socket => {
console.log('--> ', 'ns-chat: comming')
socket.on('hi', d => {
console.log('hi from client: ', d)
})
socket.emit('a message', {
that: 'only',
'/chat': 'will get',
})
chat.emit('a message', {
everyone: 'in',
'/chat': 'will get',
})
})
const news = io.of('/news').on('connection', function(socket) {
console.log('--> ', 'ns-news: comming')
socket.on('woot', d => console.log('woot from client: ', d))
socket.emit('item', { news: 'item' })
})
weapp-client.js
const chat = io('http://localhost:3000/chat')
const news = io('http://localhost:3000/news')
chat.on('a message', function(d) {
console.log('chat got: ', d)
chat.emit('hi', 'hi server')
})
news.on('item', function(d) {
console.log('news got: ', d)
news.emit('woot', { woot: 'server' })
})
Results:
server side:
--> ns-chat: comming
--> ns-news: comming
hi from client: hi server
hi from client: hi server
woot from client: { woot: 'server' }
client side:
chat got: {that: "only", /chat: "will get"}
chat got: {everyone: "in", /chat: "will get"}
news got: {news: "item"}
from weapp.socket.io.
Related Issues (20)
- 用了一下,请教! HOT 1
- 服务端我用的2.x版本,这个是否支持呢? HOT 1
- 微信小程序出现bug
- 服务端socket.io @4 能用这个包吗? HOT 9
- 能支持socket.io-client 4.6.1最新版本吗? HOT 2
- WebSocket was closed before the connection was established HOT 4
- Converting circular structure to JSON --> starting at object with constructor 'c' | property 'io' -> object with constructor 'f' | property 'nsps' -> object with constructor 'Object' --- property '//undefined//undefined' closes the circle at JSON.stringify (<anonymous>) at cloneWithData (vendor.js? [sm]:9037) at VueComponent.patch [as __patch__] (vendor.js? [sm]:9050) at VueComponent.Vue._update (vendor.js? [sm]:7359) at VueComponent.updateComponent (vendor.js? [sm]:9118) at Watcher.get (vendor.js? [sm]:7819) at Watcher.run (vendor.js? [sm]:7894) at flushSchedulerQueue (vendor.js? [sm]:7650) at Array.<anonymous> (vendor.js? [sm]:5389) at flushCallbacks (vendor.js? [sm]:5317)(env: Windows,mp,1.06.2307260; lib: 3.1.0)
- 客服端发的消息,服务端会同时收到两条一样的 HOT 1
- 提一个非常实用的小建议:剔除socket.io-client依赖。 HOT 2
- npm 安装使用无效, 用源码编译出来的js直接使用可以.
- IOS 11.2 不支持...扩展ES6语法 HOT 2
- 小程序重复退出、再次进入操作socket连接报错:websocket was closed before the connection was established
- 3.0.0版本在微信小程序分包里面调用connect时,真机上预览、体验版均会报错
- 目前是不是不支持polling模式? HOT 2
- TypeError: io is not a function HOT 2
- 能不能出一个client版本是2.X的版本 HOT 1
- 想请教这个包的目的到底什么? HOT 3
- 为什么yarn install 和npm install生成的weapp.socket.io.js不一样呢?
- 请教python flask-socketio不兼容这个微信小程序js文件,报错"GET /socket.io/?EIO=4&transport=websocket HTTP/1.1" 400 ,是本项目依赖的socket.io-client版本太低了吗?
- 请问支持支付宝小程序吗? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weapp.socket.io.