A javascript connector for BCI2000
bci2k.js relies on a binary server called BCI2000Web, which allows browsers to communicate with Operator using the Operator Scripting language and stream data in to the browser using websockets.
npm install --save bci2k
import { BCI2K_OperatorConnection } from "./dist/index.js";
const bciOperator = new BCI2K_OperatorConnection();
(async () => {
try{
await bciOperator.connect("ws://127.0.0.1")
console.log("Connected"))
} catch(err){
console.log(err)
}
})()
bciOperator.showWindow();
bciOperator.hideWindow();
bciOperator.resetSystem();
bciOperator.start();
bciOperator.getVersion();
bciOperator.execute("args"); //args are any BCI2000 Operator commands
import { BCI2K_DataConnection } from "./dist/index.js";
async () => {
let bciSourceConnection = new BCI2K_DataConnection();
try{
await bciSourceConnection.connect("ws://localhost:20100")
bciSourceConnection.onStateFormat = data => console.log(data);
bciSourceConnection.onSignalProperties = data => console.log(data);
bciSourceConnection.onGenericSignal = data => console.log(data);}
}
catch(err){
console.log(err);
}
npm run build
npm run dev