* ci: less retries for cypress
waste of cpu cycles and time, produces misleading output
* test: fix workspace tests
* chore: drop flaky af tests
* fix: Avoid sending `"undefined"` as docname
- no more "can subscribe X"
- add a new util function on socket `has_permission`
Basic usage:
```js
socket.has_permission(doctype, [name]).then(() => { // do something });
```
You can now specify custom event handlers for SocketIO.
Usage:
1. In your app's hooks.py add `has_realtime_event_handlers=True` so
Framework can assume your app contains custom handler and import them.
2. Create a file called `/app/realtime/handlers.js` with single module
export a function that will setup handlers using socket.
Here's sample code:
```js
// This is /app_root/realtime/handler.js`
function chat_app_handlers(socket) {
socket.on("hello_chat") {
console.log("hello world!");
}
}
module.exports = chat_app_handlers;
```
3. Restart SocketIO server and see if it worked by sending event from
client. In desk based app you can do
`frappe.realtime.socket.emit("hello_chat")`
Middlewares are not yet possible... will be worked upon __some other day__ [tm]
closes https://github.com/frappe/frappe/issues/21528
Earlier socketio only worked in browser where browser would send cookie
(cause same domain) and hence socketio server used it to auth
connection.
This however is limited and doesn't allow simply creating socket
connection from apps.
Authorization headers on other hand are simple to implement.
* build(deps): update redis client to v4 in legacy mode
* fix: node17+ - prefer ipv4
* chore: use redis client v4 api (async) and adapt error handling
* fix: timeout by exiting if not in watch mode
* fix: parse message before republishing
---------
Co-authored-by: Ankush Menat <ankush@frappe.io>
* fix: gently log the port on which the realtime service listens
without this, the service remains completely silent (e.g. in overmind) and it is hard to tell if it is even running
* Revert "fix: gently log the port on which the realtime service listens"
This reverts commit 14a21989c6767520d8e1b9d46cc9f58a45768563.
* refactor(socketio): explicitly listen on port
---------
Co-authored-by: Ankush Menat <ankush@frappe.io>
Establishing 1 connection for every website visit is too much.
Only after calling frappe.realtime.on(...) for ANY event, we will
establish a websocket connection.
This is used for handful of things:
- Discussion component
- File upload
Socketio was initially added here: https://github.com/frappe/frappe/pull/6866 this use case no longer exists.
Rarely anywhere website uses realtime.