Author and send a new WebSocket message
Categories
(DevTools :: Netmonitor, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: Harald, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed, Whiteboard: good-first-bug)
Option 1: Exposed as secondary toolbar:
(Toggles 2nd toolbar)
↓
1st toolbar: [🗑] [All ▼] [ Filter Messages ] [➕]
Optional 2nd toolbar: [ Plain Message Text ] [Send]
Option 2: Add form below messages table (where the message will appear). Skip the Send button and use enter-to-send (Console-style).
Prior art:
Reporter | ||
Comment 1•5 years ago
|
||
Honza: I assume this needs some backend work. Is this a good first bug or rather a small-scope enhancement for the 20% backlog?
Comment 2•5 years ago
|
||
I think that I can provide enough instructions (for DevTools part) to make this good first bug but, we are missing API on the platform.
The WebSocket Inspector is based on nsIWebSocketEventService
and nsIWebSocketEventListener
but, I don't see any way to send a frame (from within the DevTools UI).
What we need is API that would allow us to specify an existing WS connection using its ID and a payload to send. Something as follows:
nsIWebSocketEventService.send(aWebSocketSerialID, payload);
Where aWebSocketSerialID
is the ID we get from the platform in nsIWebSocketEventListener
callbacks and payload
can be a string, blob or array buffer I guess.
Baku, we are thinking about this new feature - allowing the user to send WS frames from within the DevTools UI.
It would be great to know the scope of the platform work before we put this on anybody's roadmap.
What do you think how complex it would be to implement such API?
Honza
Comment 3•5 years ago
|
||
This is relatively simple to do with nsIWebSocketEventListener if this listener runs on the same process as the webSocket object.
If this is the case, here is what we can do:
- each WebSocketImpl can be registered as weak-ref into WebSocketEventSource
- we implement nsIWebSocketEventService.send(aWebSocketSerialID, payload)
- the payload is received by the webSocketImpl and sent through the network on the correct thread.
In theory, the payload can be a string, an arrayBuffer/view or a Blob. How can support all these types from the UI?
I don't have time to work on this, but I can review code and/or mentor somebody.
Reporter | ||
Comment 4•5 years ago
|
||
In theory, the payload can be a string, an arrayBuffer/view or a Blob. How can support all these types from the UI?
MVP should just be string
support.
Comment 5•5 years ago
|
||
This is relatively simple to do with nsIWebSocketEventListener if this listener runs on the same process as the webSocket object.
Is this assumption correct?
Comment 6•5 years ago
|
||
So, we handle WS messages here:
https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/devtools/server/actors/network-monitor/websocket-actor.js#100
And this code is running on the content process.
Andrea, I assume the webSocket object is also running on the content process, correct?
Honza
Comment 7•5 years ago
|
||
Andrea, I assume the webSocket object is also running on the content process, correct?
This is correct.
Updated•5 years ago
|
Comment 8•4 years ago
|
||
The backend stuff is done and UX pointers available.
Marking as good first bug.
Honza
Updated•2 years ago
|
Description
•