Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize WeChat Mini Programs's Socket.io client

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to achieve WeChat Mini Programs's Socket.io client", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "WeChat Mini Programs's Socket.io client how to achieve" article.

Community

Slack

Weapp-socket-io

WeChat Mini Programs's Socket.io client implementation, the volume is 16K after compression.

In order to get developers started at the lowest cost, this class library encapsulates API that is consistent with socket.io for developers to call.

Demo

The Mini Program chat room application implemented by chat demo server on the official website of socket.io uses the "Wechat developer tool" to open the weapp_demo directory and run debugging.

Features

Currently supported

Namespace

Singleton

Reconnect

Build

Npm run build

Production environment can be compressed and compiled using NODE_ENV=production npm run build

How to usenpm

Npm install wxapp-socket-io

Manual

Copy the index.js file from the dist directory to your project directory and require

Const io = require ('yourPath/build/index.js')

In order to use it in exactly the same style as socket.io

Const news = io ('ws://localhost:9999/news') news.on (' news', function (data) {console.log ('= news data:', data) news.emit ('old',' 1234abc')}) const chat = io ('ws://localhost:9999/chat') console.log (' chat:', chat) chat.on ('chat', function (data) {console.log (' = chat data:', data) chat.emit ('comment') 'Hi server chat')}) Collaborator

Gongzili

C.C.

TODO

Emit buffer

Binary support

Support for Room

Smaller size

The above is about the content of this article on "how to achieve WeChat Mini Programs's Socket.io client". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report