Search in sources :

Example 1 with IRemoteCallListener

use of org.eclipse.ecf.remoteservice.IRemoteCallListener in project ecf by eclipse.

the class RpcRemoteServiceTest method testAsyncCallWithListener.

public void testAsyncCallWithListener() throws Exception {
    IRemoteService rpcClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registrationCalc.getReference());
    rpcClientService.callAsync(getCalcPlusCall(), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                Object response = cce.getResponse();
                assertTrue(response instanceof Integer);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(10000);
}
Also used : IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 2 with IRemoteCallListener

use of org.eclipse.ecf.remoteservice.IRemoteCallListener in project ecf by eclipse.

the class SimpleTest method testSimpleClientAndServerWithCallAsyncListener.

public void testSimpleClientAndServerWithCallAsyncListener() throws Exception {
    IRemoteService remoteService = client.getRemoteService();
    assertNotNull(remoteService);
    // Use callSync
    remoteService.callAsync(getRemoteConcatCall(TEST_STRING_2, TEST_STRING_1), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                result = (String) ((IRemoteCallCompleteEvent) event).getResponse();
            }
        }
    });
    Thread.sleep(1000);
    assertNotNull(result);
    assertTrue(result.equals(TEST_STRING_2 + TEST_STRING_1));
}
Also used : IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 3 with IRemoteCallListener

use of org.eclipse.ecf.remoteservice.IRemoteCallListener in project ecf by eclipse.

the class TwitterRemoteServiceTest method testAsyncCallWithListener.

public void testAsyncCallWithListener() throws Exception {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    restClientService.callAsync(RestCallFactory.createRestCall(IUserTimeline.class.getName() + ".getUserStatuses"), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                Object response = cce.getResponse();
                assertTrue(response instanceof IUserStatus[]);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(10000);
}
Also used : JSONObject(org.json.JSONObject) IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 4 with IRemoteCallListener

use of org.eclipse.ecf.remoteservice.IRemoteCallListener in project ecf by eclipse.

the class AbstractRemoteServiceAccessTest method testCallAsync.

public void testCallAsync() throws Exception {
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValid(remoteReferences);
    final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call asynchronously
    rs.callAsync(createRemoteCall(), new IRemoteCallListener() {

        public void handleEvent(final IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                final Object result = ((IRemoteCallCompleteEvent) event).getResponse();
                Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
                assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(REGISTER_WAIT);
}
Also used : IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent) ServiceReference(org.osgi.framework.ServiceReference)

Example 5 with IRemoteCallListener

use of org.eclipse.ecf.remoteservice.IRemoteCallListener in project ecf by eclipse.

the class SSLSimpleTest method testSimpleClientAndServerWithCallAsyncListener.

public void testSimpleClientAndServerWithCallAsyncListener() throws Exception {
    IRemoteService remoteService = client.getRemoteService();
    assertNotNull(remoteService);
    // Use callSync
    remoteService.callAsync(getRemoteConcatCall(TEST_STRING_2, TEST_STRING_1), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                result = (String) ((IRemoteCallCompleteEvent) event).getResponse();
            }
        }
    });
    Thread.sleep(1000);
    assertNotNull(result);
    assertTrue(result.equals(TEST_STRING_2 + TEST_STRING_1));
}
Also used : IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Aggregations

IRemoteCallListener (org.eclipse.ecf.remoteservice.IRemoteCallListener)7 IRemoteCallCompleteEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)7 IRemoteCallEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallEvent)7 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)6 ServiceReference (org.osgi.framework.ServiceReference)2 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)1 JSONObject (org.json.JSONObject)1