use of io.joynr.messaging.websocket.JoynrWebSocketEndpoint in project joynr by bmwcarit.
the class WebSocketJettyClientFactory method create.
@Override
public synchronized JoynrWebSocketEndpoint create(WebSocketAddress serverAddress) {
if (!jettyClientsMap.containsKey(serverAddress)) {
JoynrWebSocketEndpoint jettyClient = new WebSocketJettyClient(serverAddress, ownAddress, maxMessageSize, reconnectDelay, websocketIdleTimeout, objectMapper);
jettyClientsMap.put(serverAddress, jettyClient);
}
return jettyClientsMap.get(serverAddress);
}
use of io.joynr.messaging.websocket.JoynrWebSocketEndpoint in project joynr by bmwcarit.
the class WebSocketProviderProxyEnd2EndTest method testWebsocketReconnect.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testWebsocketReconnect() throws InterruptedException {
int result;
ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
// Test rpc before connection is lost
result = proxy.addNumbers(6, 3, 2);
assertEquals(11, result);
// simulate losing connection
WebSocketEndpointFactory ccWebSocketServerFactory = injectorCC.getInstance(WebSocketEndpointFactory.class);
WebSocketAddress serverAddress = injectorCC.getInstance(Key.get(WebSocketAddress.class, Names.named(WebsocketModule.WEBSOCKET_SERVER_ADDRESS)));
JoynrWebSocketEndpoint ccWebSocketServer = ccWebSocketServerFactory.create(serverAddress);
ccWebSocketServer.shutdown();
Thread.sleep(1000);
ccWebSocketServer.start();
Thread.sleep(1000);
result = proxy.addNumbers(7, 8, 1);
assertEquals(16, result);
}
Aggregations