This is a library based on event emiter/receiver that you can use to sync echo arena with bhaptics products
- ws
- node-fetch
- Windows
- Linux (using ipfinder mock)
npm i --save echomodlib
TactPlayer(tact, ipFinder, configLoader, sendEvent, listenEvent) Init the module, you can use custom mock. Check structure here: (https://github.com/NotBlue-Dev/EchoVR-Lib/tree/main/src). This is a basic code to init and start the backend (this should be in your main.js/app.js)
Arguments
tact
-Module
TactJs Adapter (Connection side)
ipFinder
-Module
Ip finder for the quest (resolve promise)
configLoader
-Module
Loader for default and config.json
sendEvent
-Function
your event emitter function with (channel,args) as options
listenEvent
-Module
your event listener function with (channel,args) as options
Important
To start checking for bhaptic players after your TactPlayer is defined YourTactPlayer.launch()
Examples
const EchoLib = require('echomodlib')
const events = require('events');
const eventEmitter = new events.EventEmitter();
const sendEvent = (channel, args) => {
eventEmitter.emit(channel, args);
}
const listenEvent = (channel, callable) => {
eventEmitter.on(channel, callable);
}
const player = new EchoLib.TactPlayer(
new EchoLib.BHapticsTactJsAdapter(),
new EchoLib.IpFinder(),
new EchoLib.ConfigLoader(__dirname),
sendEvent,
listenEvent
)
player.launch()
Here are all the events you can listen on
When all the .tact files are loaded this event is triggered
Arguments
none
Examples
eventEmitter.on('tact-device-fileLoaded', () => {
//Your code
});
On connecting to the bhaptics player
Arguments
none
Examples
eventEmitter.on('tact-device-connecting', () => {
//Your code
});
When the lib is connected to bhaptics player
Arguments
none
Examples
eventEmitter.on('tact-device-connected', () => {
//Your code
});
When the lib is disconnected from bhaptics player
Arguments
message
Examples
eventEmitter.on('tact-device-disconnected', (args) => {
//Your code
});
When the ip is found (manual or scanning)
Arguments
definedIp
The ip defined
Examples
eventEmitter.on('game-ip-defined', (args) => {
//Your code
});
When the ip is not found or invalid
Arguments
definedIp
The ip defined
Examples
eventEmitter.on('game-ip-bad-defined', (args) => {
//Your code
});
When config saving fail
Arguments
none
Examples
eventEmitter.on('config-save-failed', () => {
//Your code
});
When config saving succed
Arguments
none
Examples
eventEmitter.on('config-save-success', () => {
//Your code
});
When ip finder is canceled by user
Arguments
none
Examples
eventEmitter.on('find-ip-canceled', () => {
//Your code
});
When ip finder is resolve promise with timeout (no ip found)
Arguments
none
Examples
eventEmitter.on('find-ip-timeout', () => {
//Your code
});
When ip finder can't find ip
Arguments
err
Error returned
Examples
eventEmitter.on('find-ip-failed', (args) => {
//Your code
});
Update of intensity or if disable/enable (Triggered by event emiter get-settings)
Arguments
effects
Return an object of effects (intensity and status)
Examples
eventEmitter.on('settings-updated', (args) => {
//Your code
});
Triggered by event emiter get-data
Arguments
statusIp
Return IP
statusIpValid
Return if the ip is valid (false if not)
statusHaptic
State of bhaptics player
logs
return array with all logs
Examples
eventEmitter.on('data-updated', (args) => {
//Your code
});
Here are all the events you can trigger
Scan for ip and return event if error is triggered, else it define game ip
Arguments
device
Device type Quest
or PC
Examples
eventEmitter.emit('find-ip', "Quest")
Manually define ip (automatically triggered if ip is found by find-ip)
Arguments
ip
Ip you want to set
Examples
eventEmitter.emit('define-ip', "192.168.1.53")
Write Data to config file (config failed/success will automatically be emit after)
Arguments
none
Examples
eventEmitter.emit('save-config', () => {
//Your code
})
It need to be call on each settings change like status or intensity, this will set effect settings to api.js
Arguments
effect
Name of your effect
status
it will enable or disable the effect (enable or disable)
Examples
eventEmitter.emit('change-setting', {
effect: names,
status,
})
Play effect on bhaptics products
Arguments
effect
Name of the effect you want to play
Examples
eventEmitter.emit('play-effect', {
effect: names,
})
Reset settings by default (config.json content will be replaced by default.json content)
Arguments
none
Examples
eventEmitter.emit('default-settings', () => {
//Your code
})
This will update the config object for api.js
Arguments
none
Examples
eventEmitter.emit('get-settings', () => {
//Your code
})
This will update objects for api.js, (StatusIP, Is ip valid, status of bhaptic player, logs array) Required when you load your renderer (For example if you go from settings to your main, get-data need to be emit by your main)
Arguments
none
Examples
eventEmitter.emit('get-data', () => {
//Your code
})
If you want to make a box with logs, you need to send log through this event (so the backend save them in an array)
Arguments
loggingMessage
A string of the message you want to log
Examples
eventEmitter.emit('log', loggingMessage)
The request is automatically started when ip is found and bhaptic player is running, but you can run it manually with this event
Arguments
none
Examples
eventEmitter.emit('startRequest', () => {
//Your code
})
You can "stop" request (this will just stop interaction and effects)
Arguments
none
Examples
eventEmitter.emit('stopRequest', () => {
//Your code
})
MIT