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

regoch-websocket-angular

v1.0.1

Published

Websocket Client for Angular which works best with the Regoch Websocket Server.

Downloads

6

Readme

regoch-websocket-angular

Websocket Client for Angular framework which works best with the Regoch Websocket Server.

Very small but very powerful library made according to RFC6455 Standard for websocket version 13.

Installation

npm install --save regoch-websocket-angular

Website

www.regoch.org

Websocket Server Features

  • websocket version: 13
  • subprotocol: jsonRWS
  • chat in the rooms
  • small file size
  • integrate Angular Service
  • powerful API
  • possible RxJS integration
  • Router
  • helper

Development

npm run dev

How to use

  1. Inject service RegochWebsocketAngularService in the module
//// app.module.ts /////
import { RegochWebsocketAngularService } from 'regoch-websocket-angular';

... providers: [RegochWebsocketAngularService] ...
  1. Init services RegochWebsocketAngularService, Router and Helper
//// app.component.ts /////
import { RegochWebsocketAngularService } from 'regoch-websocket-angular';

constructor(
    public rwa: RegochWebsocketAngularService
  ) {
    const wcOpts = {
      wsURL: 'ws://localhost:3211?authkey=TRTmrt',
      timeout: 3 * 1000, // wait 3secs for answer
      reconnectAttempts: 5, // try to reconnect 5 times
      reconnectDelay: 3000, // delay between reconnections is 3 seconds
      subprotocols: ['jsonRWS'],
      debug: true
    };
    this.rwa.setOpts(wcOpts);

    // init router and helper
    this.router = new Router({debug: false});
    this.helper = new Helper();
  }

async connectMe(): Promise<void> {
    const wsocket = await this.rwa.connect();
    console.log('+++Connected', wsocket);
    this.messageReceiver();
  }
<!--app.component.ts -->
<button (click)="connectMe()">Connect</button>
<button (click)="rwa.disconnect()">Disconnect</button>

API

  • connect() - connect to the websocket server

  • disconnect() - disconnect from the websocket server

  • infoSocketId() - receive the client's socket id

  • infoSocketList() - receive the list of sockets connected on the server

  • infoRoomList() - receive the list of all rooms

  • infoRoomListmy() - receive the list of subscribed rooms

  • sendOne(to:number, msg:any) - send message to one websocket socket/client (parameter to is the socket ID)

  • send(to:number[], msg:any) - send message to one or more clients

  • broadcast(msg:any) - send message to all clients except the sender

  • sendAll(msg:any) - send message to all clients and the sender

  • roomEnter(roomName:string) - enter the room and start to listen the room's messages

  • roomExit(roomName:string) - exit from the room and stop to listen the room's messages

  • roomExitAll() - exit from the all rooms

  • roomSend(roomName:string, msg:any) - exit from the room and stop to listen the room's messages

  • setNick(nickname:string) - set the client's nickname

  • route(uri:string, body?:any) - send route to the server, for example: {uri: '/login', body: {username: 'john', password: 'trtmrt'}}

  • on(eventName:string, listener:Function) - listen events: 'connected', 'message', 'route'

  • once(eventName:string, listener:Function) - listen events: 'connected', 'message', 'route' only once

subprotocol "jsonRWS"

Subprotocol description: The subprotocol is created for communication between websocket server and client.

Subprotocol definitons: a) Client have to send message in valid JSON format. Fields: {id:number, from:number, tonumber|string|number[], cmd:string, payload?:any} b) Server have to send message in valid JSON format. Fields: {id:number, from:number, tonumber|string|number[], cmd:string, payload?:any} c) The incoming message is converted from string to object. d) The outgoing message is converted from object to string.

Licence

“Freely you received, freely you give”, Matthew 10:5-8

Copyright (c) 2020 Saša Mikodanić licensed under AGPL-3.0 .