![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@alshdavid/chi
Advanced tools
Lightweight utilities for use with the Node standard http library
Bidirectional communication using server sent events
Server
import * as http from 'node:http'
import { ServerSentEvents } from '@alshdavid/chi'
const hostname = '0.0.0.0';
const port = 3000;
const sse = new ServerSentEvents()
// Run when a new client connects
sse.on_connect(({ id }) => {
console.log('Connected', id)
// Broadcast to all connected clients
sse.send_all({ message: 'New client joined!', id })
// When a specific client sends message
sse.on_message(id, (msg) => {
console.log('from client', id, msg)
})
// Send a message to a specific client
setTimeout(async () => {
while (true) {
sse.send(id, { message: 'Hello!' })
await new Promise(res => setTimeout(res, 1000))
}
})
})
// Listen for a message from all clients
sse.on_message_all((id, msg) => {
console.log('from client (all)', id, msg)
})
// Run when a new client disconnects
sse.on_disconnect(({ id }) => {
console.log('Disconnected', id)
})
// Set up a standard HTTP server
const server = http.createServer(async (req, res) => {
// Add route for server-to-client
if (req.url === '/sse' && req.method === 'GET') {
await sse.http_handler_on_connection(req, res)
return
}
// Add route for client-to-server
if (req.url === '/sse' && req.method === 'POST') {
await sse.http_handler_on_message(req, res)
return
}
res.statusCode = 404
res.end()
})
server.listen(port, hostname, () => {
console.log(`Server running on http://${hostname}:${port}/`);
});
Client
import { SSEClient } from '@alshdavid/chi'
const sse = new SSEClient({
endpoint: '/sse',
})
sse.on(msg => console.log(msg))
sse.send({ message: 'hello world' })
FAQs
Lightweight utilities for use with the Node standard http library
The npm package @alshdavid/chi receives a total of 3 weekly downloads. As such, @alshdavid/chi popularity was classified as not popular.
We found that @alshdavid/chi 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.