13
13
package org .asynchttpclient .ws ;
14
14
15
15
import java .io .Closeable ;
16
+ import java .net .SocketAddress ;
16
17
17
18
/**
18
19
* A Websocket client
19
20
*/
20
21
public interface WebSocket extends Closeable {
21
22
23
+ /**
24
+ * Get remote address client initiated request to.
25
+ *
26
+ * @return remote address client initiated request to, may be {@code null}
27
+ * if asynchronous provider is unable to provide the remote address
28
+ */
29
+ SocketAddress getRemoteAddress ();
30
+
31
+ /**
32
+ * Get local address client initiated request from.
33
+ *
34
+ * @return local address client initiated request from, may be {@code null}
35
+ * if asynchronous provider is unable to provide the local address
36
+ */
37
+ SocketAddress getLocalAddress ();
38
+
22
39
/**
23
40
* Send a byte message.
41
+ *
24
42
* @param message a byte message
25
43
* @return this
26
44
*/
@@ -30,75 +48,78 @@ public interface WebSocket extends Closeable {
30
48
* Allows streaming of multiple binary fragments.
31
49
*
32
50
* @param fragment binary fragment.
33
- * @param last flag indicating whether or not this is the last fragment.
34
- *
51
+ * @param last flag indicating whether or not this is the last fragment.
52
+ *
35
53
* @return this.
36
54
*/
37
55
WebSocket stream (byte [] fragment , boolean last );
38
56
39
57
/**
40
58
* Allows streaming of multiple binary fragments.
41
- *
59
+ *
42
60
* @param fragment binary fragment.
43
- * @param offset starting offset.
44
- * @param len length.
45
- * @param last flag indicating whether or not this is the last fragment.
61
+ * @param offset starting offset.
62
+ * @param len length.
63
+ * @param last flag indicating whether or not this is the last fragment.
46
64
* @return this.
47
65
*/
48
66
WebSocket stream (byte [] fragment , int offset , int len , boolean last );
49
67
50
68
/**
51
69
* Send a text message
70
+ *
52
71
* @param message a text message
53
72
* @return this.
54
73
*/
55
74
WebSocket sendMessage (String message );
56
75
57
76
/**
58
77
* Allows streaming of multiple text fragments.
59
- *
78
+ *
60
79
* @param fragment text fragment.
61
- * @param last flag indicating whether or not this is the last fragment.
80
+ * @param last flag indicating whether or not this is the last fragment.
62
81
* @return this.
63
82
*/
64
83
WebSocket stream (String fragment , boolean last );
65
84
66
85
/**
67
86
* Send a <code>ping</ping> with an optional payload
68
87
* (limited to 125 bytes or less).
69
- *
88
+ *
70
89
* @param payload the ping payload.
71
- *
90
+ *
72
91
* @return this.
73
92
*/
74
93
WebSocket sendPing (byte [] payload );
75
94
76
95
/**
77
96
* Send a <code>ping</ping> with an optional payload
78
97
* (limited to 125 bytes or less).
79
- *
98
+ *
80
99
* @param payload the pong payload.
81
100
* @return this.
82
101
*/
83
102
WebSocket sendPong (byte [] payload );
84
103
85
104
/**
86
105
* Add a {@link WebSocketListener}
106
+ *
87
107
* @param l a {@link WebSocketListener}
88
108
* @return this
89
109
*/
90
110
WebSocket addWebSocketListener (WebSocketListener l );
91
111
92
112
/**
93
113
* Add a {@link WebSocketListener}
114
+ *
94
115
* @param l a {@link WebSocketListener}
95
116
* @return this
96
117
*/
97
118
WebSocket removeWebSocketListener (WebSocketListener l );
98
119
99
120
/**
100
121
* Returns <code>true</code> if the WebSocket is open/connected.
101
- *
122
+ *
102
123
* @return <code>true</code> if the WebSocket is open/connected.
103
124
*/
104
125
boolean isOpen ();
@@ -108,4 +129,3 @@ public interface WebSocket extends Closeable {
108
129
*/
109
130
void close ();
110
131
}
111
-
0 commit comments