17
17
package io .vertx .ext .stomp .impl ;
18
18
19
19
import io .vertx .core .Vertx ;
20
- import io .vertx .ext .stomp .Command ;
21
- import io .vertx .ext .stomp .Destination ;
22
- import io .vertx .ext .stomp .Frame ;
23
- import io .vertx .ext .stomp .StompServerConnection ;
20
+ import io .vertx .ext .stomp .*;
24
21
import io .vertx .ext .stomp .utils .Headers ;
25
22
26
23
import java .util .ArrayList ;
@@ -58,12 +55,12 @@ public String destination() {
58
55
/**
59
56
* Dispatches the given frame.
60
57
*
61
- * @param connection the connection
62
- * @param frame the frame ({@code SEND} frame).
58
+ * @param connection the connection
59
+ * @param frame the frame
60
+ * @param payloadMode only for websocket bridge, explicitely specify payload type or null
63
61
* @return the current instance of {@link Destination}
64
62
*/
65
- @ Override
66
- public synchronized Destination dispatch (StompServerConnection connection , Frame frame ) {
63
+ private synchronized Destination dispatch (StompServerConnection connection , Frame frame , PayloadMode payloadMode ) {
67
64
if (subscriptions .isEmpty ()) {
68
65
lastUsedSubscriptions = -1 ;
69
66
return this ;
@@ -72,10 +69,29 @@ public synchronized Destination dispatch(StompServerConnection connection, Frame
72
69
String messageId = UUID .randomUUID ().toString ();
73
70
Frame message = transform (frame , subscription , messageId );
74
71
subscription .enqueue (message );
75
- subscription .connection ().write (message );
72
+ if (payloadMode != null ) {
73
+ subscription .connection .write (message , payloadMode );
74
+ } else {
75
+ subscription .connection .write (message );
76
+ }
76
77
return this ;
77
78
}
78
79
80
+ @ Override
81
+ public Destination dispatch (StompServerConnection connection , Frame frame ) {
82
+ return dispatch (connection , frame , null );
83
+ }
84
+
85
+ @ Override
86
+ public Destination dispatchText (StompServerConnection connection , Frame frame ) {
87
+ return dispatch (connection , frame , PayloadMode .TEXT );
88
+ }
89
+
90
+ @ Override
91
+ public Destination dispatchBinary (StompServerConnection connection , Frame frame ) {
92
+ return dispatch (connection , frame , PayloadMode .BINARY );
93
+ }
94
+
79
95
private Subscription getNextSubscription () {
80
96
lastUsedSubscriptions = lastUsedSubscriptions + 1 ;
81
97
if (lastUsedSubscriptions >= subscriptions .size ()) {
0 commit comments