gotty/js/spice-web-client/process/mainprocess.js
Soren L. Hansen c66ae7b2e4 First, primitive stab at SPiCE integration
Launch an Xspice and run:
echo -ne "\033]844;127.0.0.1;9876\007"

This will launch a SPiCE client connecting to 127.0.0.1:9876.

Still need to add all the security stuff and generally be
more defensive in the implementation.
2021-04-16 06:50:05 -07:00

53 lines
1.7 KiB
JavaScript

wdi.MainProcess = $.spcExtend(wdi.EventObject.prototype, {
init: function(c) {
this.superInit();
this.app = c.app;
this.spiceConnection = c.app.spiceConnection;
this.agent = c.app.agent;
},
process: function(spiceMessage) {
var channel = this.spiceConnection.channels[wdi.SpiceVars.SPICE_CHANNEL_MAIN];
switch(spiceMessage.messageType) {
case wdi.SpiceVars.SPICE_MSG_MAIN_INIT:
channel.connectionId = spiceMessage.args.session_id;
channel.fire('connectionId', channel.connectionId);
if(spiceMessage.args.agent_connected == 1) {
channel.fire('initAgent', spiceMessage.args.agent_tokens);
}
if (spiceMessage.args.current_mouse_mode == 1) {
channel.fire('mouseMode', spiceMessage.args.current_mouse_mode);
}
// the mouse mode must be change both if we have agent or not
this.changeMouseMode();
break;
case wdi.SpiceVars.SPICE_MSG_MAIN_AGENT_DATA:
var packet = spiceMessage.args;
this.agent.onAgentData(packet);
break;
case wdi.SpiceVars.SPICE_MSG_MAIN_AGENT_CONNECTED:
channel.fire('initAgent', spiceMessage.args.agent_tokens);
this.changeMouseMode();
break;
case wdi.SpiceVars.SPICE_MSG_MAIN_MULTI_MEDIA_TIME:
this.app.multimediaTime = spiceMessage.args.multimedia_time;
break;
case wdi.SpiceVars.SPICE_MSG_MAIN_CHANNELS_LIST:
channel.fire('channelListAvailable', spiceMessage.args.channels);
break;
}
},
changeMouseMode: function() {
var packet = new wdi.SpiceMessage({
messageType: wdi.SpiceVars.SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,
channel: wdi.SpiceVars.SPICE_CHANNEL_MAIN,
args: new wdi.SpiceMouseModeRequest({
request_mode: 2
})
});
this.spiceConnection.send(packet);
}
});