You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: javascript/ql/src/semmle/javascript/frameworks/WebSocket.qll
+45-38Lines changed: 45 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
/**
2
-
* Provides classes for working with [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).
2
+
* Provides classes for working with [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) and [ws](https://github.com/websockets/ws).
3
3
*
4
-
* The model is based on the EventEmitter model, and there a therefore a
4
+
* The model is based on the EventEmitter model, and there is therefore a
5
5
* data-flow step from where a WebSocket event is send to where the message
6
6
* is received.
7
7
*
8
-
* WebSockets include no concept of channels, therefore every client can send
9
-
* to every server (and vice versa).
8
+
* Data flow is modeled both from clients to servers, and from servers to clients.
9
+
* The model models that clients can send messages to all servers, and servers can send messages to all clients.
10
10
*/
11
11
12
12
import javascript
@@ -18,6 +18,9 @@ import javascript
18
18
*/
19
19
privatestringchannelName(){result="message"}
20
20
21
+
/**
22
+
* Provides classes that model WebSockets clients.
23
+
*/
21
24
module ClientWebSocket {
22
25
/**
23
26
* A class that can be used to instantiate a WebSocket instance.
@@ -69,55 +72,59 @@ module ClientWebSocket {
69
72
}
70
73
71
74
/**
72
-
* Gets a methodName that can be used to register a listener for WebSocket messages on a given socket.
75
+
* A handler that is registered to receive messages from a WebSocket.
* A handler that is registered to receive messages from a WebSocket.
83
-
*
84
-
* If the registration happens with the "addEventListener" method or the "onmessage" setter property, then the handler receives an event with a "data" property.
85
-
* Otherwise the handler receives the data directly.
86
-
*
87
-
* This confusing API is caused by the "ws" library only mostly using their own API, where event objects are not used.
88
-
* But the "ws" library additionally supports the WebSocket API from browsers, which exclusively use event objects with a "data" property.
84
+
* Gets a handler, that is registered using method `methodName` and receives messages send to `emitter`.
0 commit comments