npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@qsocket/core

v0.0.1-rc

Published

Powerful inter-process communication library for browser and Node.js environments, with flexible transport support including WebSocket, TCP, Unix Sockets, and Windows Pipes. Delivers high-performance data exchange through byte-stream buffers and automatic

Downloads

271

Readme

@qsocket/core

npm version npm downloads GitHub license

@qsocket/core is a powerful and versatile library for inter-process communication, enabling seamless data exchange both in the browser and in Node.js environments. Leveraging the @qsocket/protocol package to convert data into a byte-stream (buffer) format, @qsocket/core allows for diverse data types to be transmitted within a single message, preserving the integrity and structure of information. With built-in automatic packet compression, it minimizes network load and improves performance when handling large volumes of data.

The core strength of @qsocket/core lies in its flexibility and readiness to work with a wide range of transport options: WebSocket, LongPolling, TCP sockets, file sockets, Unix sockets, and Windows Pipes. Currently, the library supports engine.io for data transmission, but future updates will expand support for additional transport options.

Stay updated on the latest developments in the @qsocket/transport package—an essential tool for working with @qsocket/core. This package provides standardized, tested, and wrapped transports that easily integrate with @qsocket/core. This approach allows you to flexibly manage the transport layer without altering your core application code. @qsocket/transport guarantees stability, scalability, and growth potential for your application, allowing @qsocket/core to remain the reliable, trusted backbone of your communication layer.

With @qsocket/core, you gain reliability, scalability, and peak efficiency—everything you need for stable and fast inter-process communication, essential for applications where inter-process interaction is mission-critical.

Key Features

  • Multi-Transport Support: Currently supports engine.io; future releases will add TCP sockets, file sockets, Unix sockets, and Windows Pipes.
  • Buffer-Based Data Transfer: All data is transmitted as buffers, enabling efficient handling of binary data.
  • Flexible Interface: The library interacts with transports via a unified interface, making it easy to add support for new transport protocols.
  • Namespace and Event Handling: Support for namespaces and events makes it easy to organize and manage data exchange logic between client and server.
  • Configurable Data Compression: Option to enable data compression (GZIP and DEFLATE) with customizable thresholds and algorithms.

Installation

To install QSocket and the necessary transport package, use the following command:

```bash npm install @qsocket/core @qsocket/transport ```

Usage

Server

Create a QSocket server with engine.io as the transport:

```typescript import { QSocketServer } from '@qsocket/core'; import { createEngineIOLatest } from '@qsocket/transport'; import { createServer } from 'http';

const httpServer = createServer(); httpServer.listen(3000);

const transport = createEngineIOLatest(httpServer); const server = new QSocketServer(transport, { compressor: { on: true, compressionFromSize: 1024 * 100, // Enable compression for messages larger than 100 KB }, debugConfig: { on: true, prefix: '[QSocket Server]', }, });

// Create a namespace const namespace = server.createNamespace('chat');

// Handle an event within the namespace namespace.on('connection', (connection) => { connection.on('event', (data) => { console.log('Message received:', data); return void 0; // must return a value }); connection.emit('event', 'Hello, Client'); }); ```

Client

Set up a QSocket client using engine.io:

```typescript import { QSocketClient } from '@qsocket/core'; import { createEngineIOClientLatest } from '@qsocket/transport';

const transport = createEngineIOClientLatest('http://example.com'); const client = new QSocketClient(transport, { compressor: { on: true, }, debugConfig: { on: true, prefix: '[QSocket Client]', }, });

// Connect to a namespace client.createNamespace('chat'); ```

API

QSocketServer

Creates a QSocket server instance with the ability to manage namespaces and events.

Constructor

```typescript new QSocketServer(transport: TQSocketServer, protocolConfig: IQSocketProtocolConfig, debugConfig?: IQSocketDebugConfig); ```

QSocketClient

Creates a QSocket client instance for connecting to a server and exchanging data.

Constructor

```typescript new QSocketClient(socket: TQSocketClientSocket, protocolConfig?: IQSocketProtocolConfig, debugConfig?: IQSocketDebugConfig); ```

Configuration

Protocol Options

IQSocketProtocolConfig

  • compressor: Data compression settings.
    • on: Enable or disable compression.
    • compressionFromSize: Threshold for enabling compression (in bytes).
    • compressor: Custom compressor instance (optional).

IQSocketDebugConfig

Debug configuration:

  • on: Enable or disable debug mode.
  • prefix: Prefix for debug messages.
  • logger: Custom logger.

Example Integration with Other Transports

QSocket initially supports engine.io, but its architecture allows integration with other transport types, such as TCP or file sockets, in the future. Any transport simply needs to implement interfaces similar to those in engine.io.

License

This project is licensed under the MIT License.

Contributing

If you have suggestions or ideas for improvement, please open an issue or submit a pull request in the project's GitHub repository.