简体   繁体   English

我如何将 websockets 与 gjs(Gnome JavaScript)一起使用?

[英]How do I use websockets with gjs(Gnome JavaScript)?

I am trying to create a simple application in GJS that sends desktop notifications based on json received via WebSocket. What is the easiest way to use WebSocket in GJS?我正在尝试在 GJS 中创建一个简单的应用程序,它根据通过 WebSocket 收到的 json 发送桌面通知。在 GJS 中使用 WebSocket 的最简单方法是什么? Thanks in advance.提前致谢。

I wrote an example here https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/websocket-client.js我在这里写了一个例子https://gitlab.gnome.org/GNOME/gjs/-/blob/master/examples/websocket-client.js

If you would like to use a similar API to browsers, have a look at https://github.com/sonnyp/troll如果您想在浏览器中使用类似的 API,请查看https://github.com/sonnyp/troll

In GJS you'll probably have to use libsoup for this.在 GJS 中,您可能必须为此使用 libsoup。

The GJS documentation is at https://gjs-docs.gnome.org/soup30 , such as the Soup.WebSocketConnection . GJS 文档位于https://gjs-docs.gnome.org/soup30 ,例如Soup.WebSocketConnection

You'll probably also want to read the upstream documentation which includes some introductory material.您可能还想阅读包含一些介绍性材料的上游文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM