mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
initial error reply unpacking, client emits 'error' event
This commit is contained in:
parent
ebb8dfaabf
commit
85fe833e9f
1 changed files with 16 additions and 3 deletions
|
|
@ -185,12 +185,25 @@ XClient.prototype.expectReplyHeader = function()
|
||||||
var type = res[0];
|
var type = res[0];
|
||||||
var seq_num = res[2];
|
var seq_num = res[2];
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
{
|
{
|
||||||
var error_code = res[1];
|
var error_code = res[1];
|
||||||
|
var error = {};
|
||||||
|
error.code = error_code;
|
||||||
|
error.seq = seq_num;
|
||||||
|
error.message = xerrors.errorText[error_code];
|
||||||
|
|
||||||
// unpack error packet (32 bytes for all error types, 8 of them in CCSL header)
|
// unpack error packet (32 bytes for all error types, 8 of them in CCSL header)
|
||||||
client.pack_stream.get(24, function(buf) {
|
client.pack_stream.get(24, function(buf) {
|
||||||
// TODO: dispatch, use sequence number
|
// TODO: dispatch, use sequence number
|
||||||
console.error('error!!!!' + xerrors.errorText[error_code]);
|
//TODO: add more generic way to read common values
|
||||||
|
// if (error_code == 14)
|
||||||
|
{
|
||||||
|
var res = buf.unpack('LSC');
|
||||||
|
error.badPparam = res[0]; // id: GC, WinID, Font, Atom etc; Value
|
||||||
|
error.minorOpcode = res[1];
|
||||||
|
error.majorOpcode = res[2];
|
||||||
|
}
|
||||||
|
client.emit('error', error);
|
||||||
client.expectReplyHeader();
|
client.expectReplyHeader();
|
||||||
} );
|
} );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue