@@ -191,10 +191,6 @@ public static class WSWholeTextHandler implements NginxJavaRingHandler {
191
191
public Object [] invoke (Map <String , Object > request ) throws IOException {
192
192
NginxJavaRequest r = (NginxJavaRequest )request ;
193
193
NginxHttpServerChannel sc = r .hijack (true );
194
- //If we use nginx directive `auto_upgrade_ws on;`, these three lines can be omitted.
195
- if (!sc .webSocketUpgrade (true )) {
196
- return null ;
197
- }
198
194
sc .addListener (sc , new WholeMessageAdapter <NginxHttpServerChannel >(9 *1024 ) {
199
195
/* (non-Javadoc)
200
196
* @see nginx.clojure.WholeMessageAdapter#onWholeTextMessage(java.lang.Object, java.lang.String)
@@ -204,6 +200,12 @@ public void onWholeTextMessage(NginxHttpServerChannel ch, String message) throws
204
200
ch .send (message , true , false );
205
201
}
206
202
});
203
+
204
+ //If we use nginx directive `auto_upgrade_ws on;`, these three lines can be omitted.
205
+ if (!sc .webSocketUpgrade (true )) {
206
+ return null ;
207
+ }
208
+
207
209
return null ;
208
210
}
209
211
}
@@ -214,10 +216,7 @@ public static class WSWholeMessageHandler implements NginxJavaRingHandler {
214
216
public Object [] invoke (Map <String , Object > request ) throws IOException {
215
217
NginxJavaRequest r = (NginxJavaRequest )request ;
216
218
NginxHttpServerChannel sc = r .hijack (true );
217
- //If we use nginx directive `auto_upgrade_ws on;`, these three lines can be omitted.
218
- if (!sc .webSocketUpgrade (true )) {
219
- return null ;
220
- }
219
+
221
220
sc .addListener (sc , new WholeMessageAdapter <NginxHttpServerChannel >(64 *1024 ) {
222
221
/* (non-Javadoc)
223
222
* @see nginx.clojure.WholeMessageAdapter#onWholeTextMessage(java.lang.Object, java.lang.String)
@@ -235,6 +234,12 @@ public void onWholeBiniaryMessage(NginxHttpServerChannel ch, ByteBuffer message)
235
234
ch .send (message , true , false );
236
235
}
237
236
});
237
+
238
+ //If we use nginx directive `auto_upgrade_ws on;`, these three lines can be omitted.
239
+ if (!sc .webSocketUpgrade (true )) {
240
+ return null ;
241
+ }
242
+
238
243
return null ;
239
244
}
240
245
}
0 commit comments