mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
spice-html5 updated.
This commit is contained in:
parent
12c80c5021
commit
b05a252d7c
36 changed files with 1356 additions and 1415 deletions
static/js/spice-html5
85
static/js/spice-html5/port.js
Executable file
85
static/js/spice-html5/port.js
Executable file
|
@ -0,0 +1,85 @@
|
|||
"use strict";
|
||||
/*
|
||||
Copyright (C) 2016 by Oliver Gutierrez <ogutsua@gmail.com>
|
||||
Miroslav Chodil <mchodil@redhat.com>
|
||||
|
||||
This file is part of spice-html5.
|
||||
|
||||
spice-html5 is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
spice-html5 is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with spice-html5. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
** SpicePortConn
|
||||
** Drive the Spice Port Channel
|
||||
**--------------------------------------------------------------------------*/
|
||||
function SpicePortConn()
|
||||
{
|
||||
DEBUG > 0 && console.log('SPICE port: created SPICE port channel. Args:', arguments);
|
||||
SpiceConn.apply(this, arguments);
|
||||
this.port_name = null;
|
||||
}
|
||||
|
||||
SpicePortConn.prototype = Object.create(SpiceConn.prototype);
|
||||
|
||||
SpicePortConn.prototype.process_channel_message = function(msg)
|
||||
{
|
||||
if (msg.type == SPICE_MSG_PORT_INIT)
|
||||
{
|
||||
if (this.port_name === null)
|
||||
{
|
||||
var m = new SpiceMsgPortInit(msg.data);
|
||||
this.portName = arraybuffer_to_str(new Uint8Array(m.name));
|
||||
this.portOpened = m.opened
|
||||
DEBUG > 0 && console.log('SPICE port: Port', this.portName, 'initialized');
|
||||
return true;
|
||||
}
|
||||
|
||||
DEBUG > 0 && console.log('SPICE port: Port', this.port_name, 'is already initialized.');
|
||||
}
|
||||
else if (msg.type == SPICE_MSG_PORT_EVENT)
|
||||
{
|
||||
DEBUG > 0 && console.log('SPICE port: Port event received for', this.portName, msg);
|
||||
var event = new CustomEvent('spice-port-event', {
|
||||
detail: {
|
||||
channel: this,
|
||||
spiceEvent: new Uint8Array(msg.data)
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
|
||||
window.dispatchEvent(event);
|
||||
return true;
|
||||
}
|
||||
else if (msg.type == SPICE_MSG_SPICEVMC_DATA)
|
||||
{
|
||||
DEBUG > 0 && console.log('SPICE port: Data received in port', this.portName, msg);
|
||||
var event = new CustomEvent('spice-port-data', {
|
||||
detail: {
|
||||
channel: this,
|
||||
data: msg.data
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
window.dispatchEvent(event);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG > 0 && console.log('SPICE port: SPICE message type not recognized:', msg)
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue