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

truflux-msg-multiplexer

v1.0.0

Published

A multiplexing module to allow multiple protocols to communicate under the same socket using truflux

Downloads

5

Readme

Truflux Message Multiplexing

To install

npm install --save truflux-msg-multiplexer

This module attempts to allow multiplexing of truflux message protocols on the same truflux connection.NOTE This module will not work if you are using dynamic protocol ie continuing to add to a protocol after it has already been multiplexed.

Lets try an example. Suppose I have a single socket connection with truflux, but I want multiple protocols to use the socket harmoniously. If they are fixed protocols and they support the required structural interface of a truflux message protocol, then we can multiplex them whilst still using them as we would normally

	
var TrufluxMultiplexMessage = require('truflux-msg-multiplexer'),
	protocol1               = SomeTrufluxMessageInstance,
	protocol2               = SomeOtherTrufluxMessageInstance,
	protocol3               = yetAnotherTrufluxMessageInstance,
	multiplexer             = new TrufluxMultiplexMessage();

	multiplexer.setInitial(protocol1)
			   .multiplex (protocol2)
			   .multiplex (protocol3);

	/*
		Now lets assume we've create a truflux socket that uses the multiplexer as its msg parameter
		Since the multiplexer has shuffled the ID values , we can do the following as we would normally
	 */
	client.send(protocol1.someMessageID)
		  .send(protocol2.someOtherMessageID);

	/*
		However we cannot directly index from the id of the multiplexer, because of potential protocol name collisions .Suffice to say because of this you cannot multiplex another multiplexer
	*/

	//multiplexer.id.someMessageID

	/*
		Additionally because of this we cannot do the following because there is no id lookup, 
		so you must provide the number value from the individualized protocols;
	*/ 
	client.send('someMessageID');

	//DO NOT continue to add more to the truflux message protocols after this 

##API We implement the minimum needed functions for the structural interface required of a truflux message

setInitial (otherTrufluxMessage)

/**
 * Sets the inital truflux message object from which the multiplexing is based
 * @param  {TrufluxMessage} otherTrufluxMessage 
 * @return {Multiplexer}     
 */

multiplex (otherTrufluxMessage)

/**
     * Attempts to multiplex the other truflux messages protocol if it has:
     * 
     *      changeMessageID function
     *      id              Object containing a lookup to the ids  
     *
     * So that a single truflux message can encompass all of it but still work individually within their old contexts 
     *
     * @param  {TrufluxMessage} otherTrufluxMessage 
     * @throws {Error}          If otherTrufluxMessage does not support the required functions
     * @return {Multiplexer}                      
     */   

call(id,payload,socket)

/**
 * Calls the handler associated with the message ID. NOTE This will throw an error if there is no 
 * handler associated. It is assumed you have called "has" before hand
 * @param  {Number} id      
 * @param  {Any} payload 
 * @param  {TrufluxSocket} socket
 * @return {TrufluxMessage}   
 */

has(messageID)

/**
 * Checks to see if it has the specified message handler
 * @param  {Number}  messageID 
 * @return {Boolean}       
 */