crevice-client

0.1.0 • Public • Published

Crevice(client)

License Bun Node.js WebSocket

Crevice is a lightweight, high-performance WebSocket service for secure 1:1 real-time communication with end-to-end encryption, capable of handling large data volumes.

🚀 Features

  • Lightweight: Optimized for minimal resource usage
  • High Performance: Built with Bun and Node.js for blazing-fast execution
  • Secure: End-to-end encryption for all communications
  • Real-time: Instant message delivery using WebSocket
  • Scalable: Designed to handle large volumes of data
  • 1:1 Communication: Focused on private, direct messaging
  • Batteries Included: Includes a client for easy integration

🔧 Usage

To run the client:

cd client

Install dependencies:

pnpm install

Start the client:

pnpm test
pnpm test [roomId]

If you want to join a room, you can specify the room ID as an argument.

SDK

The client SDK is available as a separate package. To install the SDK:

pnpm install crevice-client

You can use the SDK as follows:

import { CreviceClient } from '../src/crevice.client';
import readline from 'readline';

const baseUrl: string = 'ws://localhost:5000';
const roomId: string | undefined = process.argv[2];

const onRoomCreated = (roomId: string) => {
  console.log('Room created:', roomId);
  promptUser();
};

const onOpen = (roomId: string) => {
  console.log('Connection established:', roomId);
  promptUser();
};

const onError = (error: Error) => {
  console.error('Connection error:', error);
};

const onClose = () => {
  console.log('Connection closed');
  rl.close();
};

const client = new CreviceClient(
  baseUrl,
  (message: string) => {
    console.log('Remote message:', message);
    promptUser();
  },
  {
    roomId,
    roomCreatedCallback: onRoomCreated,
    openCallback: onOpen,
    errorCallback: onError,
    closeCallback: onClose,
  }
);

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

function promptUser(): void {
  rl.question('> (quit to exit)', (input) => {
    if (input.toLowerCase() === 'quit') {
      console.log('Exiting...');
      client.close();
      rl.close();
    } else {
      try {
        client.send(input);
        console.log('You: ' + input);
        promptUser();
      } catch (error) {
        console.error('Message sending error:', error);
        promptUser();
      }
    }
  });
}

console.log('Connecting to server...');

Readme

Keywords

none

Package Sidebar

Install

npm i crevice-client

Weekly Downloads

0

Version

0.1.0

License

ISC

Unpacked Size

23 kB

Total Files

6

Last publish

Collaborators

  • lukas.j.han