Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
IORequest 是一个基于 socket.io 的双向 request 库。
IORequest 同时支持客户端向服务端发送请求以及服务端向客户端发送请求。
node
npm install io-request
浏览器
<script src="dist/browser/io-request-client.js"></script>
服务端
const server = require('http').createServer()
const io = require('socket.io')(server)
const {IORequestServer} = require('io-request')
const ioReqServer = new IORequestServer(io)
// 定义服务端 echo 请求的 handler
ioReqServer.handle('echo', ({response, data}) => {
response(data)
})
io.on('connection', socket => {
socket.on('io-connect', () => {
// 向客户端端发送 echo 请求
socket.ioRequest({method: 'echo', data: 'hello client'})
.then(data => console.log('客户端返回:' + JSON.stringify(data)))
})
})
server.listen(8080)
客户端
const socket = io()
const ioReqClient = new IORequestClient(socket)
// 定义客户端 echo 请求的 handler
ioReqClient.handle('echo', ({response, data}) => {
response(data)
})
socket.on('io-connect', () => {
socket.ioRequest({method: 'echo', data: 'hello server'})
.then(data => console.log('服务端返回:' + data))
})
FAQs
https://github.com/bramblex/io-request.git
The npm package io-request receives a total of 4 weekly downloads. As such, io-request popularity was classified as not popular.
We found that io-request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.