Skip to content

Commit 9aea349

Browse files
committed
Support invoking receivers with no arguments
1 parent bd8bfd0 commit 9aea349

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/AndroidClient/client/src/main/java/net/servicestack/client/sse/ServerEventsClient.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,23 @@ public void execute(ServerEventsClient client, ServerEventMessage msg) {
238238
if (!Modifier.isPublic(mi.getModifiers()) || Modifier.isStatic(mi.getModifiers()))
239239
continue;
240240
Class[] args = mi.getParameterTypes();
241-
if (args.length != 1)
241+
if (args.length > 1)
242242
continue;
243243
if ("equals".equals(mi.getName()))
244244
continue;
245245

246+
String actionName = mi.getName();
247+
if (!target.equalsIgnoreCase(actionName) && actionName.startsWith("set"))
248+
actionName = actionName.substring(3); //= "set".length()
249+
250+
if (args.length == 0){
251+
if (target.equalsIgnoreCase(actionName)) {
252+
mi.invoke(receiver, null);
253+
return;
254+
}
255+
continue;
256+
}
257+
246258
Class requestType = args[0];
247259

248260
if (target.equals(requestType.getSimpleName()) &&
@@ -254,10 +266,6 @@ public void execute(ServerEventsClient client, ServerEventMessage msg) {
254266
return;
255267
}
256268

257-
String actionName = mi.getName();
258-
if (!target.equalsIgnoreCase(actionName) && actionName.startsWith("set"))
259-
actionName = actionName.substring(3); //= "set".length()
260-
261269
if (target.equalsIgnoreCase(actionName)) {
262270
Object request = !Utils.isNullOrEmpty(msg.getJson())
263271
? JsonUtils.fromJson(msg.getJson(), requestType)

src/AndroidClient/client/src/test/java/net/servicestack/client/TestJavaScriptReceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public void announce(String message)
3131
AnnounceInstance = message;
3232
}
3333

34-
public void toggle(String message)
34+
public void toggle()
3535
{
36-
ToggleReceived = message;
36+
ToggleReceived = "";
3737
ToggleRequestReceived = super.getRequest();
3838
}
3939

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy