-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[POC] WS browser events #1895
[POC] WS browser events #1895
Conversation
@@ -6,7 +6,7 @@ | |||
<title> | |||
console.redhat.com | |||
</title> | |||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https: wss: data: 'unsafe-inline' 'unsafe-eval' https://*.redhat.com/ https://www.redhat.com https://*.openshift.com/ https://api.stage.openshift.com/ https://identity.api.openshift.com/ https://www.youtube.com/ https://redhat.sc.omtrdc.net/ https://assets.adobedtm.com https://www.redhat.com https://*.storage.googleapis.com/ https://*.hotjar.com:* https://*.hotjar.io wss://*.hotjar.com;"> | |||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https: wss: data: 'unsafe-inline' 'unsafe-eval' ws://localhost:8080 https://*.redhat.com/ https://www.redhat.com https://*.openshift.com/ https://api.stage.openshift.com/ https://identity.api.openshift.com/ https://www.youtube.com/ https://redhat.sc.omtrdc.net/ https://assets.adobedtm.com https://www.redhat.com https://*.storage.googleapis.com/ https://*.hotjar.com:* https://*.hotjar.io wss://*.hotjar.com;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about wss:
? Also, shouldn't there be a wss:///.redhat.com
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't take these seriously we I don't even know where the service will live
'toggle-notifications-drawer': notificationsDrawerReducer, | ||
'add-notification': addNewNotificationReducer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these into constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. This is just a draft to demo the features. Do not take anything seriously, only the concept.
* Establish connection | ||
*/ | ||
useEffect(() => { | ||
const x = new WebSocket('ws://localhost:8080/ws'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather see a proxy config in webpack for websockets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to do some research on this. I am not sure how the webpack proxy works with WS. Not sure if our implementation will work properly.
Object.values(events.current) | ||
.flat() | ||
.forEach((cb) => { | ||
cb(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd check if the callback is defined in here
cb(payload); | |
cb?.(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's checked when a callback is registered. It will not register listener if a callback is not a function
Obsolete |
Description
This is a POC of the upcoming dynamic browser events service (web sockets in short)
It adds two main features
The WS service is not published anywhere yet but it does these things
chrome-events
channel. Tapping into existing channels might be an issue due to frequency and due to the fact that the messages probably do not follow strict structures.The WS service has 3 types of granularity setup
Each message can have multiple targets. Meaning that we can send a message to more than tenants or users or combinations.
Do not take any code seriously it will change. The Notification drawer has a high priority as it is a future requirement.
Let me know your thoughts. You can check this RBAC POC to see advanced caching and data invalidation options: RedHatInsights/insights-rbac-ui#1139.