@@ -52,12 +52,11 @@ struct WebSocketWrapper {
5252 Isolate *isolate = args.GetIsolate ();
5353 auto *ws = getWebSocket<SSL>(args);
5454 if (ws) {
55- NativeString topic (isolate, args[0 ]);
55+ NativeString< true > topic (isolate, args[0 ]);
5656 if (topic.isInvalid (args)) {
5757 return ;
5858 }
59- bool nonStrict = args.Length () > 1 && args[1 ]->BooleanValue (isolate);
60- bool success = ws->subscribe (topic.getString (), nonStrict);
59+ bool success = ws->subscribe (topic.getString ());
6160 args.GetReturnValue ().Set (Boolean::New (isolate, success));
6261 }
6362 }
@@ -68,12 +67,11 @@ struct WebSocketWrapper {
6867 Isolate *isolate = args.GetIsolate ();
6968 auto *ws = getWebSocket<SSL>(args);
7069 if (ws) {
71- NativeString topic (isolate, args[0 ]);
70+ NativeString< true > topic (isolate, args[0 ]);
7271 if (topic.isInvalid (args)) {
7372 return ;
7473 }
75- bool nonStrict = args.Length () > 1 && args[1 ]->BooleanValue (isolate);
76- bool success = ws->unsubscribe (topic.getString (), nonStrict);
74+ bool success = ws->unsubscribe (topic.getString ());
7775 args.GetReturnValue ().Set (Boolean::New (isolate, success));
7876 }
7977 }
@@ -88,16 +86,19 @@ struct WebSocketWrapper {
8886 return ;
8987 }
9088
91- NativeString topic (isolate, args[0 ]);
89+ bool isBinary = args[2 ]->BooleanValue (isolate);
90+ bool compress = args[3 ]->BooleanValue (isolate);
91+
92+ NativeString<true > topic (isolate, args[0 ]);
9293 if (topic.isInvalid (args)) {
9394 return ;
9495 }
95- NativeString message (isolate, args[1 ]);
96+ NativeString< true > message (isolate, args[1 ]);
9697 if (message.isInvalid (args)) {
9798 return ;
9899 }
99100
100- bool success = ws->publish (topic.getString (), message.getString (), args[ 2 ]-> BooleanValue (isolate) ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, args[ 3 ]-> BooleanValue (isolate) );
101+ bool success = ws->publish (topic.getString (), message.getString (), isBinary ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, compress );
101102 args.GetReturnValue ().Set (Boolean::New (isolate, success));
102103 }
103104 }
@@ -126,7 +127,7 @@ struct WebSocketWrapper {
126127 code = args[0 ]->Uint32Value (isolate->GetCurrentContext ()).ToChecked ();
127128 }
128129
129- NativeString message (args.GetIsolate (), args[1 ]);
130+ NativeString< true > message (args.GetIsolate (), args[1 ]);
130131 if (message.isInvalid (args)) {
131132 return ;
132133 }
@@ -239,12 +240,16 @@ struct WebSocketWrapper {
239240 Isolate *isolate = args.GetIsolate ();
240241 auto *ws = getWebSocket<SSL>(args);
241242 if (ws) {
242- NativeString message (args.GetIsolate (), args[0 ]);
243+
244+ bool isBinary = args[1 ]->BooleanValue (isolate);
245+ bool compress = args[2 ]->BooleanValue (isolate)
246+
247+ NativeString<true > message (args.GetIsolate (), args[0 ]);
243248 if (message.isInvalid (args)) {
244249 return ;
245250 }
246251
247- unsigned int sendStatus = ws->send (message.getString (), args[ 1 ]-> BooleanValue (isolate) ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, args[ 2 ]-> BooleanValue (isolate) );
252+ unsigned int sendStatus = ws->send (message.getString (), isBinary ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, compress );
248253
249254 args.GetReturnValue ().Set (Integer::NewFromUnsigned (isolate, sendStatus));
250255 }
@@ -256,7 +261,7 @@ struct WebSocketWrapper {
256261 Isolate *isolate = args.GetIsolate ();
257262 auto *ws = getWebSocket<SSL>(args);
258263 if (ws) {
259- NativeString topic (args.GetIsolate (), args[0 ]);
264+ NativeString< true > topic (args.GetIsolate (), args[0 ]);
260265 if (topic.isInvalid (args)) {
261266 return ;
262267 }
@@ -273,7 +278,7 @@ struct WebSocketWrapper {
273278 Isolate *isolate = args.GetIsolate ();
274279 auto *ws = getWebSocket<SSL>(args);
275280 if (ws) {
276- NativeString message (args.GetIsolate (), args[0 ]);
281+ NativeString< true > message (args.GetIsolate (), args[0 ]);
277282 if (message.isInvalid (args)) {
278283 return ;
279284 }
0 commit comments