Skip to content

MGelein/trinn-remote-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TRINN Remote Control

This package allows for simple remote control of applications over WebRTC.

Installation

The package can be installed using npm:

npm i trinn-remote-control

Example Usage

After the package has been installed you now have access to two classes: TRINNController and TRINNRemote.

//remote.js

const remote = new TRINNRemote("SomeSharedId");

remote.onPress((key) => {
  console.log(`${key} was pressed`);
});

remote.onRelease((key) => {
  console.log(`${key} was released`);
});

remote.onData((object) => {
  console.log(object);
});

remote.sendData({ type: "bicycle", amount: 5 });
//controller.js

const controller = new TRINNController("SomeSharedId");

document.addEventListener("keydown", (e) => {
  controller.sendPress(e.key);
});

document.addEventListener("keyup", (e) => {
  controller.sendRelease(e.key);
});

controller.sendData({ type: "bicycle", amount: 5 });

controller.onData((object) => {
  console.log(object);
});

Known Issues

Because this library depends on PeerJS we are unfortunately not able to support SSR at this time

Todo

  • Add configurable PeerJS server

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published