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

@pepperdash/mobile-control-react-app-core

v1.20.0

Published

Core components for PepperDash Mobile Control React Apps

Downloads

128

Readme

Mobile Control React App Core Library

This library uses vite for React.

The purpose of this library is to provide the necessary building blocks to make developing React apps for Mobile Control easier and more efficient.

Primarily, it provides a series of React hooks that handle API interaction with corresponding messengers in the Essentials Mobile Control Plugin (or other Essentials plugins) as well as typescript interfaces for the device state objects that each messenger uses.

In addition, it also provides some core React components that can be consumed by a React App and deal with the particulars of running an HTML5 app on a touch device and allow interaction between button events to achieve press/hold/release functionality commonly necessary for things like ramping volume controls or sending IR commands.

At the core of this library is a React Context that is intended to generate a websocket client that handles all the messaging to and from the Mobile Control Plugin. Along with that context, Redux is used to handle maintining the state for the room and all devices relevant to the current session. Redux selectors are provided for accessing common data in the store by room or device.

How Mobile Control Works

Mobile control uses a websocket to allow JSON formatted messages to be passed between the client app, running in React, and the Essentials Control System application.

When the client initially connects to the control system, it makes an HTTP call to join a particular room. The response to that call provides the React app with the necessary information to connect to the websocket server. The server can either be running directly on the Crestron control system processor or it can also be running on the Mobile Control Edge Server, which then acts as a message relay to the control system.

Once a websocket connection is established, the React app must then request the room state and configuration which it will subsequently use to determine which device states it needs to request from the control system.

Supplied in this library is a hook (useGetAllDeviceStateFromRoomConfiguration) that takes a RoomConfiguration object and will then iterate the devices for that room and request their current full status. This hook should be called at the root level of the React App.

From that point forward, room and device state messages from the control system will be partial objects and will get overlayed onto the room/device state object in the store.

How this Library is Intended to be Used

The intent is to use the various hooks provided in this library to easily link up to buttons and other elements on an HTML5 UI in a React App to handle the heavy lifting of integrating with the Mobile Control API. This library will provide hooks for the messengers in the Mobile Control plugin, but you will also be able to write hooks in the React App for custom API that can integrate directly with a messenger defined in any Essentials room or device plugin. This allows consistency with the core communication that most systems will rely on, while also providing easy customization and extensibility for more esoteric or application specific needs that may not see wide use and justify inclusion in this library.

How to Set up Your Development Environment

Run npm install to install the required dependencies.

Load an instance of an Essentials v2.x program as well as the Essentials Mobile Control plugin v4.x to a Crestron program slot. Consult the Mobile Control plugin for direct server plugin configuration instructions.

Copy the /public/_local-config/_config.default.json to a file called /public/_local-config/_config.local.json and modify the apiPath value to point to the IP address of your test processor as well as the correct port. This file should not be added to the git repository because it applies only to your local test environment.

Run the app with npm run dev which will start the development server. The vite development server will then print it's local URL (eg: http://localhost:5173/mc/app). Open this URL in a browser. Initially you will just get a message saying that the client is disconnected. You will need to supply a token in the url as a search param that will associate your client with a particular client instance on the Mobile Control server. To get a token, run the mobileinfo:[programSlot] console command on the Crestron processor and copy the token value associated with the client instance you want your development client to connect to and paste it into the url as the token value (eg: http://localhost:5173/mc/app?token=[some-token-value]).

Your development client instance should now connect to the websocket server running on the Crestron program.