=?UTF-8?Q?Re:_[Gnome_Shell_Extensions]_Reading?= =?UTF-8?Q?_from_a_socket_with_GJS_--failure_to_read_from_Gio.?= =?UTF-8?Q?InputStream?=



Thanks for your quick reply!
What do you mean by "(out caller-allocates) (array length=length)"? What would be the correct args for read() be?


Dnia 5 sierpnia 2012 17:17 "Jasper St. Pierre" <jstpierre mecheye net> napisał(a):

> Hm, it seems the method is improperly annotated. It should be (out
> caller-allocates) (array length=length).
> 
> On Sun, Aug 5, 2012 at 7:55 AM, gdfc <gdfc o2 pl> wrote:
> > Hello!
> >
> > 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!
> >
> > BR
> >
> > gdfc
> >
> > [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
> > _______________________________________________
> > gnome-shell-list mailing list
> > gnome-shell-list gnome org
> > https://mail.gnome.org/mailman/listinfo/gnome-shell-list
> 
> 
> 
> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]