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-remote-control-client

v0.0.2

Published

Client-side of Websocket-remote-control, a library to link two devices and exchange info.

Downloads

12

Readme

websocket-remote-control-client

Websockets-remote-control is a JS project that provides two libraries: a client and a server that can link two devices through websockets.

This library initializes the Websockets client. Here, the screen and controller features are used. Both parts can be customized with different configurations to take advantage of its set of actions.

Usage

Installation

npm install websocket-remote-control-client

Example

In the /demo folder

Creation

Socket.io script should be added in every HTML file that uses the library before de body tag is closed.

<script src="/socket.io/socket.io.js"></script>

You can instantiate a Screen or Controller object in a script tag or in a separate file and import it.

Screen

To create a WebControlScreen object:

const WebControlScreen = require('websocket-remote-control-client').WebControlScreen

const webControlScreen = new WebControlScreen('serverUrl', actions, specialNumberTag)

Where serverUrl is the url to the websockets server, actions is a list of actions, for example, ['urlRedirect'] and specialNumberTag is the HTML tag id where the Special Number will be displayed.

Controller

To create a WebControlController object:

const WebControlController = require('websocket-remote-control-client').WebControlController

const webControlController = new WebControlController('serverUrl')

Where serverUrl is the url to the websockets server.

Actions

The superclass Webcontrol models the generic behaviour of WebControlScreen and WebControlController.

Webcontrol has a dictionary called ACTIONS. Different actions will be performed depending which class uses it (screen or controller). Also, CUSTOMACTIONS dictionary is present for the user to add any functionality they need.

The screen actions present in ACTIONS are:

  • 'urlRedirect': redirects the current screen to the received url.

  • 'getSpecialNumber': sets the Special Number into the HTML tag selected at initialization. In addition, saves the Special Number in the Session Storage (with the key specialNumber).

The controller actions present in ACTIONS are:

  • 'linkController': if the response is not an error, then the data received is a Special Number. The Special Number is saved on the sessionStorage and the widgetOn variable is set to true.

The CUSTOMACTIONS present are:

  • 'sendData': sends the Special Number to the server to pair both devices.

Methods

  • linkController(specialNumber): sends the special number to the server in order to be paired.

  • postAlreadyLinked(function): a function executed just after the pairing is done. In our example in the demo folder, this function is used to show or hide a QR widget.

  • send(value): executes the 'sendData' action with a value (special number).

  • 'unpair': unpairs the current controller from the session. Uses the specialNumber to identify the session. In addition, receives a function to execute changes after the events are done. In the case of our example, the function used hides the widget.