Re: How to send text/data via websockets(soup_websocket_connection_send_text) within the libsoup library using GJS ?



Here you can find my implementation https://github.com/marmis85/pushbullet-gnome

I decided to use the same SoupHttpSession for both the RESTful api and the websocket connection, so I setup the http part of the session in pushbulletApi.js, and then the session is passed to eventStream.js to setup the websocket connection.

Actually I didn't implemented sending data, but if you look in eventStream.js, this._websocketConnection is a reference to the SoupWebsocketConnection returned by session.websocket_connect_finish(res).
You probably want to invoke send_text(text) on that object


Il giorno mar 30 ago 2016 alle ore 12:37 Aditya Mehra <aix m outlook com> ha scritto:

Hi,


My apologies to all, if this is in the wrong group.


I have been working on a gnome shell extension that utilizes websockets to communicate with the parent application and have resorted to using python to communicate via websockets in the previous versions. This is causing dependency issues and the only way I can solve this is by utilizing libsoup library implementation of websockets within the extension. I have not been able to find any documentation in regards to utilizing websockets in GJS and for a while now have been wondering around not reaching any solution. I am hoping to reach out to you for your help.  The only code I have come across implemented within GJS utilizing libsoup and websockets is the following:


    let session = new Soup.Session();
    Soup.Session.prototype.add_feature.call(session, new Soup.ProxyResolverDefault())
    session.httpAliases = ["ws"];
        
    let logger = Soup.Logger.new(Soup.LoggerLogLevel.BODY, -1);
    logger.attach(session);
    logger.set_printer(function(logger, level, direction, data) { print(data); });

    let message = new Soup.Message({
    method: "GET",
    uri: new Soup.URI('ws://localhost:8000/events')
     });

    session.websocket_connect_async(message, null, null, null, callback);
    session.websocket_connect_finish(res);

The above allows me to create a connection to my application with a request header and response callback but I am unable to find any reference to "soup_websocket_connection_send_text" method implementation in GJS which allows me to send string/text data along with my GET request. 

Request you to please help me with the above.

Regards,
Aditya Mehra

_______________________________________________
libsoup-list mailing list
libsoup-list gnome org
https://mail.gnome.org/mailman/listinfo/libsoup-list


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