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

@totemorg/socketio

v1.41.0

Published

socket.io

Downloads

32

Readme

SOCKETIO

Provides a form-fit-functional replacement for the notoriously buggy socket.io and its socket.io-client client counterpart. Like its socket.io predecessors, SocketIO provides json-based web sockets, though it also has hooks to support binary sockets (for VoIP, video, etc) applications. SocketIO provides both a server-side and client-side modules that mimic the socket.io specification (less the bugs of course).

Manage

npm install @totemorg/socketio	# install
npm run start [ ? | $ | ...]	# Unit test
npm run verminor				# Roll minor version
npm run vermajor				# Roll major version
npm run redoc					# Regen documentation

Usage

Acquire SocketIO as follows:

const SIO = require("@totemorg/socketio");

See the Program Reference for examples.

Program Reference

SOCKETIO

Replaces the buggy socket.io and socket.io-client modules. Documented in accordance with jsdoc.

ref: https://medium.com/hackernoon/implementing-a-websocket-server-with-node-js-d9b78ec5ffa8

Requires: module:@totemorg/enums, module:crypto
Author: ACMESDS
Example

On the server:

		const SIO = require("socketio");
		IO = SIO(server);					// connects socketIO to your nodejs server
		
		IO.on( "connect", socket => {		// the client automatically emits a "connect" request when it calls io()  
		
			socket.on(  "CHANNEL", (req,socket) => {			// intercepts client request made on socket to this CHANNEL
				console.log( "here is the client's request", req ); 
				socket.emit({ message: "a response" });
				IO.emit({ message: "a message for everyone!" });
				IO.emitOthers("SkipThisClient", { message: "a message for everyone!" });		// useful emit extension
				IO.clients["[email protected]"].emit({ message: "you get an extra message"});
			});
			
			// etc for other CHANNELs 

		});	
		IO.emit({ .... })  			// to emit a request to all clients

	On the client:

		// <script type="text/javascript, src="/socketio/socketio-client.js"></script>

		const
			ioSocket = io();			// connect to socketIO by emitting a "connect" request
			ioClient = "myClientName";	// set a client name to identify this socket

		ioSocket.emit("CHANNEL", {		// send request to server side on its CHANNEL
			...
		});
		
		ioSocket.on("CHANNEL", req => {
			console.log("server sent this request", req);
		});
		

	

Example

The socketio interface is established when the server does a 

		require( "socketio") 
		
	to create a socketio = "/socketio/socketio-client.js" endpoint from which the client imports its client via a 

		<script src=socketio> 
		
	to define an ioClient name.

	On the server:

		const
			SOCKETIO = require("socketio"),
			SIO = SOCKETIO(server); 	// establish sockets on provided HTTP server

		SIO.on("connect", socket => {  	// define socket listeners when client calls the socketio-client io()
			console.log("listening to sockets");

			socket.on( "join", (req,socket) => {	// trap client "join" request
			});

			// etc
		});
		
	On the client:
		
		const
			iosocket = io(); 					// connect to socketio 
			ioClient = "[email protected]";		// default client nmae

			iosocket.emit( "join", {			// send join request to server
				client: ioClient,				// usually provide with request 
				message: "can I join please?"	// optional connection info
			}); 

SOCKETIO-CLIENT

The client-side of socketio. The socketio interface is established when the server does a require( "socketio"). This require creates an endpoint at socketio from which the client imports its client via the following tag. Next we define the ioClient using this socketio.

Author: ACMESDS

SOCKETIO-CLIENT~io()

Make a connect request to the server at url||window.location.

Kind: inner method of SOCKETIO-CLIENT

Contacting, Contributing, Following

Feel free to

License

MIT


© 2012 ACMESDS