@@ -70,10 +70,35 @@ module ClientWebSocket {
70
70
/**
71
71
* A class that can be used to instantiate a WebSocket instance.
72
72
*/
73
- class SocketClass extends API :: Node {
73
+ deprecated class SocketClass extends DataFlow :: SourceNode {
74
74
LibraryName library ; // the name of the WebSocket library. Can be one of the libraries defined in `LibraryNames`.
75
75
76
76
SocketClass ( ) {
77
+ this = DataFlow:: globalVarRef ( "WebSocket" ) and library = websocket ( )
78
+ or
79
+ this = DataFlow:: moduleImport ( "ws" ) and library = ws ( )
80
+ or
81
+ // the sockjs-client library:https://www.npmjs.com/package/sockjs-client
82
+ library = sockjs ( ) and
83
+ (
84
+ this = DataFlow:: moduleImport ( "sockjs-client" ) or
85
+ this = DataFlow:: globalVarRef ( "SockJS" )
86
+ )
87
+ }
88
+
89
+ /**
90
+ * Gets the WebSocket library name.
91
+ */
92
+ LibraryName getLibrary ( ) { result = library }
93
+ }
94
+
95
+ /**
96
+ * A class that can be used to instantiate a WebSocket instance.
97
+ */
98
+ class WebSocketClass extends API:: Node {
99
+ LibraryName library ; // the name of the WebSocket library. Can be one of the libraries defined in `LibraryNames`.
100
+
101
+ WebSocketClass ( ) {
77
102
this = any ( WebSocketEntryPoint e ) .getANode ( ) and library = websocket ( )
78
103
or
79
104
this = API:: moduleImport ( "ws" ) and library = ws ( )
@@ -96,7 +121,7 @@ module ClientWebSocket {
96
121
* A client WebSocket instance.
97
122
*/
98
123
class ClientSocket extends EventEmitter:: Range , API:: NewNode , ClientRequest:: Range {
99
- SocketClass socketClass ;
124
+ WebSocketClass socketClass ;
100
125
101
126
ClientSocket ( ) { this = socketClass .getAnInvocation ( ) }
102
127
@@ -212,7 +237,18 @@ module ServerWebSocket {
212
237
/**
213
238
* Gets a server created by a library named `library`.
214
239
*/
215
- API:: InvokeNode getAServer ( LibraryName library ) {
240
+ deprecated DataFlow:: SourceNode getAServer ( LibraryName library ) {
241
+ library = ws ( ) and
242
+ result = DataFlow:: moduleImport ( "ws" ) .getAConstructorInvocation ( "Server" )
243
+ or
244
+ library = sockjs ( ) and
245
+ result = DataFlow:: moduleImport ( "sockjs" ) .getAMemberCall ( "createServer" )
246
+ }
247
+
248
+ /**
249
+ * Gets a server created by a library named `library`.
250
+ */
251
+ API:: InvokeNode getAServerInvocation ( LibraryName library ) {
216
252
library = ws ( ) and
217
253
result = API:: moduleImport ( "ws" ) .getMember ( "Server" ) .getAnInvocation ( )
218
254
or
@@ -224,7 +260,7 @@ module ServerWebSocket {
224
260
* Gets a `socket.on("connection", (msg, req) => {})` call.
225
261
*/
226
262
private DataFlow:: CallNode getAConnectionCall ( LibraryName library ) {
227
- result = getAServer ( library ) .getReturn ( ) .getMember ( EventEmitter:: on ( ) ) .getACall ( ) and
263
+ result = getAServerInvocation ( library ) .getReturn ( ) .getMember ( EventEmitter:: on ( ) ) .getACall ( ) and
228
264
result .getArgument ( 0 ) .mayHaveStringValue ( "connection" )
229
265
}
230
266
0 commit comments