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

websocket_center

v0.1.6

Published

This is a frame of websocket developers for nodejs

Downloads

5

Readme

DESCRIPTION

version: v0.1.6 author: Blind Holmes

This is a frame of websocket developers for nodejs v10.15.2

FEATURE

  • DISTRIBUTED
  • HIGH AVAILABILITY
  • HIGH PERFORMANCE
  • PURE WEBSOCKET PROTOCOL
    • SECOND WEBSOCKET PROTOCOL SUPPORT
    • NATIVE WEBSOCKET PING/PONG SUPPORT
  • EXTEND PROTOCOL SUPPORT
    • ON MESSAGE PING/PONG SUPPORT
  • REDIS CONNECTION POOL

ILLUSTRATION

USEAGE

Download the full project folder

install all package form folder root path the package.js file like:

npm install

and run app.js file with node

node app.js

then your websocket project was already run.

RULE

NOW THESE MESSAGE IS VERY IMPORTANT

This frame is not only a server use to get connection but also a client use to send command.

All message send and recive use JSON object.

DATA FORMAT

All project send message must be a json object.

Like connection.sendMsg({success: true});

THE CONFIG FILE IN /config/config.js

	this.http = {
		port: 8080
	};
	
	this.websocket = {
	    keepalive: true,
	    keepaliveInterval: 3000,
	    dropConnectionOnKeepaliveTimeout: true,
	    keepaliveGracePeriod: 60000,
	    autoAcceptConnections: false,
	    useSecProtocols: true,
	    secProtocols: 'echo-protocol'
	};
	
	// TEST CONFIG
	this.redis = {
	    host: '127.0.0.1', // default 
	    port: 6379, // default 
	    max_clients: 30, // defalut 
	    perform_checks: false, // checks for needed push/pop functionality
	    database: 0, // database number to use
	    perfix: "websocket_",
	    options: {
	    	auth_pass: '233233233'
	    } // options for createClient of node-redis, optional 
	};
	
	this.echoRule = {
	    enabled: false,
	    pingMsg: {          //INIT ping massage JSON OBJ
	        type: 'ping'
	    },
	    pongMsg: {
	        type: 'pong'    //INIT pong massage JSON OBJ
	    },
	    pingInterval: 3,    //second
	    outOfCountKickConnection: 5,   // out of this count then kick this connection
	};

	this.gatewayHostName = 'ws://192.168.10.102';

echoRule:

if your websocket keepalive ping/pong is not support by ISP.

then you can use a message ping/pong to keep connection alive.

change the enable to true to enable the message ping/pong.

pingInterval is second for send a ping message to all client pre time.

pingMsg will init the ping data format;

http:

port: The listen port number of your web server;

websocket:

keepalive: boolean of use websocket ping/pong.

keepaliveInterval: int second of every ping time.

API

  • connection.sendMsg(jsonObject)

      send to this connection a msessage with Json Object.
  • connection.sendUTF(string)

      send to this connection a msessage with String.
  • connection.close()

      close this connection.
  • connection.ping(data)

      send to this connection a websocket ping.
  • connection.pong(data)

      send to this connection a websocket pong.
  • fns.sendToRemoteClientServer(wsAddress, callback)

      send the message to remote websocket server.
      websocket address like "ws://127.0.0.1"
    
      callback param is this connection
    
      useage:
    
      fns.sendToRemoteClientServer("ws://127.0.0.1", function (connection) {
      	connection.sendMsg({msg: 'hello world'});
      });
    	
  • fns.registerWsServerAddress(wsAddress)

      register the argument to websocket address like:
    
      fns.registerWsServerAddress("ws://127.0.0.1");
  • fns.getClientIdByUniqueid(uniqueId, callback)

  • fns.bindUniqueIdToClient(uniqueId, clientId, callback)

  • fns.bindClientIdToServerAddress(clientId, serverAddress, callback)

  • fns.unbindClientId(clientId)

  • fns.sendToRemoteClient(clientId, json)

  • fns.sendToAllClient(json)

  • fns.sendToLocalClientById(clientId, msgJson)

  • fns.sendToAllLocatClient(msgJson)

  • fns.getIPAdress()

message data rule

	{
		identity: String
		command: String
		snedMsg: String
	}

identity

	this is in message send to websocket server on message only can be responseived.
	server recive date only accept identity "backend", "client", "gateway".
	like {identity: "backend"}

command

	this is in message send to websocket server on message only can be responseived.
	server recive date only accept command:

sendToClientById, sendToAllClient, sendToLocalClientById, sendToAllLocatClient. { identity: 'backend', command: 'sendToClientById', clientId: clientId, sendMsg: { type: 'count', count: count, serial: serial } };