use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class HttpPublisher method publish.
@Override
public IPromise<ActorServer> publish(Consumer<Actor> disconnectCallback) {
ActorServer actorServer;
try {
Pair<PathHandler, Undertow> serverPair = Http4K.get().getServer(port, hostName);
UndertowHttpServerConnector con = new UndertowHttpServerConnector(facade);
con.setConnectionVerifier(connectionVerifier);
con.setSessionTimeout(sessionTimeout);
actorServer = new ActorServer(con, facade, coding == null ? new Coding(SerializerType.FSTSer) : coding);
con.setActorServer(actorServer);
actorServer.start(disconnectCallback);
serverPair.getFirst().addPrefixPath(urlPath, con);
} catch (Exception e) {
Log.Warn(null, e);
return new Promise<>(null, e);
}
return new Promise<>(actorServer);
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method testWSMany.
@Test
public void testWSMany() throws Exception {
checkSequenceErrors = false;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = new WebSocketPublisher(service, "localhost", "/ws", 8081).publish().await();
RemotingTestService client = (RemotingTestService) new WebSocketConnectable(RemotingTestService.class, "ws://localhost:8081/ws").connect().await(9999999);
ExecutorService exec = Executors.newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
exec.execute(() -> {
try {
runWithClient(client, latch);
} catch (Exception e) {
e.printStackTrace();
}
});
}
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method runNio.
public void runNio(Coding coding) throws Exception {
checkSequenceErrors = true;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = NIOServerConnector.Publish(service, 8081, coding).await();
CountDownLatch latch = new CountDownLatch(1);
runnitTCP(latch, coding);
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class _JSR356ServerConnector method Publish.
public static IPromise<ActorServer> Publish(Actor facade, String path, Coding coding) {
_JSR356ServerConnector connector = new _JSR356ServerConnector();
try {
ActorServer actorServer = new ActorServer(connector, facade, coding);
actorServer.start();
ContainerProvider.getWebSocketContainer().connectToServer(connector, /*new DefaultClientEndpointConfig(),*/
new URI(path));
return new Promise<>(actorServer);
} catch (Exception e) {
e.printStackTrace();
return new Promise<>(null, e);
}
}
Aggregations