=?UTF-8?Q?Reading_from_a_socket_with_GJS_(Gnome?= =?UTF-8?Q?_Shell_extension)_--_failure_to_read_from_Gio.InputStream?=
- From: gdfc <gdfc o2 pl>
- To: javascript-list gnome org
- Subject: Reading from a socket with GJS (Gnome Shell extension) -- failure to read from Gio.InputStream
- Date: Sat, 04 Aug 2012 22:29:45 +0200
Hi!
I'm currently writing an extension for Gnome Shell using gjs and have to read some gpsd data from a socket. I've gotten this far:
const Gio = imports.gi.Gio;
let sockCl = new Gio.SocketClient();
let sockCon = sockCl.connect_to_host("localhost:2947", null, null);
let outStr = sockCon.get_output_stream();
outStr.write('?WATCH={"enable":true,"json":true};', null);
let inStr = sockCon.get_input_stream();
let b = new Array(128);
inStr.read(b, 1, null);
However, the read method always fails with the following error:
Error: Argument 'buffer' (type void) may not be null
I've tried all read* methods described in the only more or less current gjs API reference I've found [1], but they all seem to have the same problem. This is regardless of what type b is -- it can be an array, a string, a number or even a function, but it doesn't get recognised as anything other than null. I'm aware of [2] (this is the only web search result I've stumbled upon), but it is of little help.
So my question here: does anyone know a way to read from a socket in gjs? It doesn't have to be Gio, any standard lib would do... I've tried some Soup and GLib methods, but they don't seem to work either. In Gio, I do at least get the OutputStream to write reliably...
Any advice is highly appreciated. Thank you!
[1] http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gio.InputStream.html
[2] https://mail.gnome.org/archives/javascript-list/2012-January/msg00003.html
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]