1
1
'use strict' ;
2
2
3
3
var net = require ( 'net' ) ;
4
- var stompjs = require ( '@stomp/stompjs' ) ;
4
+
5
+ /**
6
+ * Possible states for the IStompSocket
7
+ */
8
+ var StompSocketState ;
9
+ ( function ( StompSocketState ) {
10
+ StompSocketState [ StompSocketState [ "CONNECTING" ] = 0 ] = "CONNECTING" ;
11
+ StompSocketState [ StompSocketState [ "OPEN" ] = 1 ] = "OPEN" ;
12
+ StompSocketState [ StompSocketState [ "CLOSING" ] = 2 ] = "CLOSING" ;
13
+ StompSocketState [ StompSocketState [ "CLOSED" ] = 3 ] = "CLOSED" ;
14
+ } ) ( StompSocketState = StompSocketState || ( StompSocketState = { } ) ) ;
15
+ /**
16
+ * Possible activation state
17
+ */
18
+ var ActivationState ;
19
+ ( function ( ActivationState ) {
20
+ ActivationState [ ActivationState [ "ACTIVE" ] = 0 ] = "ACTIVE" ;
21
+ ActivationState [ ActivationState [ "DEACTIVATING" ] = 1 ] = "DEACTIVATING" ;
22
+ ActivationState [ ActivationState [ "INACTIVE" ] = 2 ] = "INACTIVE" ;
23
+ } ) ( ActivationState = ActivationState || ( ActivationState = { } ) ) ;
5
24
6
25
/**
7
26
* Wrapper for a TCP socket to make it behave similar to the WebSocket interface
@@ -21,17 +40,17 @@ class TCPWrapper {
21
40
this . onmessage = noOp ;
22
41
this . onopen = noOp ;
23
42
this . url = `tcp://${ host } /${ port } /` ;
24
- this . readyState = stompjs . StompSocketState . CONNECTING ;
43
+ this . readyState = StompSocketState . CONNECTING ;
25
44
this . socket = this . getSocket ( port , host ) ;
26
45
this . socket . on ( 'connect' , ( ) => {
27
- this . readyState = stompjs . StompSocketState . OPEN ;
46
+ this . readyState = StompSocketState . OPEN ;
28
47
this . onopen ( ) ;
29
48
} ) ;
30
49
this . socket . on ( 'data' , ev => {
31
50
this . onmessage ( { data : ev } ) ;
32
51
} ) ;
33
52
this . socket . on ( 'close' , hadError => {
34
- this . readyState = stompjs . StompSocketState . CLOSED ;
53
+ this . readyState = StompSocketState . CLOSED ;
35
54
if ( this . _closeEvtOnTermination ) {
36
55
this . onclose ( this . _closeEvtOnTermination ) ;
37
56
}
@@ -72,14 +91,14 @@ class TCPWrapper {
72
91
* @param reason
73
92
*/
74
93
close ( code , reason ) {
75
- this . readyState = stompjs . StompSocketState . CLOSING ;
94
+ this . readyState = StompSocketState . CLOSING ;
76
95
this . socket . end ( ) ;
77
96
}
78
97
/**
79
98
* @internal
80
99
*/
81
100
terminate ( ) {
82
- this . readyState = stompjs . StompSocketState . CLOSING ;
101
+ this . readyState = StompSocketState . CLOSING ;
83
102
this . _closeEvtOnTermination = {
84
103
wasClean : false ,
85
104
type : 'CloseEvent' ,
0 commit comments