Check out our website for a glimpse at what is possible with imperio.
- Sensor event data:
- Gesture event data:
- Peer client ID information
- Room information
- Initiate streaming communication using WebSockets
- Automatically switch to WebRTC DataChannels as appropriate with one line of code
- Configurable middleware automatically creates and manages data streaming rooms for clients
- Clients connect with short, randomly generated passwords provided to room initiator
- Peristent client room connections
Install via npm:
npm install --save imperio
Getting started with imperio is simple: add a few lines in your frontend and server code. Below is some code to get a basic example running. For all available functionality, check out our API docs.
Check out the full code for the sample implementation here.
Client Side Implementation
Use imperio in your client-side code to emit and receive a wide range of sensor and gesture events and data.
imperio is attached to the window object and is accessible by
imperio once you add the script tag to your html files.
ListenerRoomSetup starts the socket room connection and listens for incoming data from other connected clients. This is generally, but not necessarily, on a desktop/main browser.
The emitter(s), generally mobile devices, will connect to the room established above.
imperio.gesture() method gives developers access to all gesture events on a touch screen enabled device. Check out the API wiki page to see the full suite of features available.
var swipeBox = document;imperio;
Server Side Implementation
imperio provides connection and authentication functionality on the server via an Express middleware.
npm install --save express
Just require the module and pass it the server object of your app
const imperio = server;
To correctly route the front-end request for the imperio bundle, include the following static route.
imperio.init() as middleware in your desired express route.
And that's it! This application will now stream swipe data from client to client, with a just a few lines of front end code and one line of middleware. Now go forth and build awesome things.
Other examples using imperio can be found in the other repos under the imperio organization and on our example page.