69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
let {addService,addListener} = require("../WebSocket.js");
|
|
|
|
const Stdoutput = [
|
|
["notifyPairInfo", true],
|
|
["packrecaive", true],
|
|
["packsending", true],
|
|
["notifyRoomInfo", true]
|
|
];
|
|
|
|
addListener('connect',(global, client)=>{
|
|
for (const [name, defaultValue] of Stdoutput)
|
|
{
|
|
client.store.set(name, defaultValue);
|
|
}
|
|
client.sync('store');
|
|
});
|
|
|
|
|
|
|
|
addService(({
|
|
client,
|
|
end,
|
|
global,
|
|
message,
|
|
next,
|
|
response
|
|
})=>{
|
|
let {type, value} = message;
|
|
switch(type)
|
|
{
|
|
// enable/disable pair/info messages
|
|
case 'connection/pairinfo':{
|
|
client.store.set("notifyPairInfo", !!value)
|
|
client.sync('store');
|
|
end(true);
|
|
break;
|
|
}
|
|
case 'connection/roominfo':{
|
|
client.store.set("notifyRoomInfo", !!value)
|
|
client.sync('store');
|
|
end(true);
|
|
break;
|
|
}
|
|
|
|
|
|
case 'connection/packrecaive':{
|
|
client.store.set("packrecaive", !!value)
|
|
client.sync('store');
|
|
end(true);
|
|
break;
|
|
}
|
|
case 'connection/packsending':{
|
|
client.store.set("packsending", !!value)
|
|
client.sync('store');
|
|
end(true);
|
|
break;
|
|
}
|
|
|
|
case 'connection/reset':{
|
|
for (const [name, defaultValue] of Stdoutput)
|
|
{
|
|
client.store.set(name, defaultValue);
|
|
}
|
|
client.sync('store');
|
|
end(true);
|
|
break;
|
|
}
|
|
}
|
|
}); |