There is a custom event which I try to dispatch via client-side API.
I use the version of Code Runner which went with the generated project for the custom event and IntelliJ IDE to debug it.
I have set breakpoints to check whether the event handler is triggered. When I dispatch the event from timer (i.e.directly), everything seems to be alright. But when I try to do it using client-side API (REST), I get “OK” response from server, but the event doesn’t seem to be triggered ( as the breakpoint isn’t hit ).
This is the code for event handler in Java ( generated via console ) :
@BackendlessEvent( "Sync_event" )
public class Sync_eventEventHandler extends com.backendless.servercode.extension.CustomEventHandler
{
@Async
@Override
public Map handleEvent( RunnerContext context, Map eventArgs )
{
System.out.println("got here");
Map result = new HashMap();
result.put("hello", "world");
return result;
}
}
This is the request I send to dispatch Sync_event:
curl -H application-id:<my-app-id>
-H secret-key:<my-secret-key>
-H application-type:REST
-H Content-Type:application/json
-X POST -d '{"hello":"world"}'
-v https://api.backendless.com/v1/servercode/events/Sync_event
Am I missing something?
Thank you.
P.S. At first I tried dispatching the event using client-side API for iOS (an async method with block-based callbacks) but I kept receiving an empty response. So I’ve switched to REST API to make it easy to check whether the event handler is triggered at all.