use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class Basics method testConnectionCloseOnCompleteWS.
@Test
public void testConnectionCloseOnCompleteWS() throws InterruptedException {
WebSocketPublisher publisher = new WebSocketPublisher().hostName("localhost").urlPath("/ws").port(8082);
ConnectableActor connectable = new WebSocketConnectable().url("ws://localhost:8082/ws");
concloseTest(publisher, connectable);
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class StatelessService method main.
public static void main(String[] args) {
StatelessServiceArgs conf = new StatelessServiceArgs();
JCommander.newBuilder().addObject(conf).build().parse(args);
StatelessService serv = AsActor(StatelessService.class);
conf.connectUrls.forEach(url -> {
Routing.registerService(new WebSocketConnectable().url(url).serType(url.endsWith("/bin") ? SerializerType.FSTSer : SerializerType.JsonNoRef), serv, x -> serv.disconnedtedCB(x), false).then((r, e) -> {
if (e != null) {
Log.Info(StatelessService.class, "error connecting krouter " + e);
if (e instanceof Throwable)
Log.Info(StatelessService.class, (Throwable) e);
} else
Log.Info(StatelessService.class, "SLService connected krouter " + url);
});
});
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class KLoadTest method run.
public void run() {
boolean http = false;
ConnectableActor connectable;
if (!http) {
connectable = new WebSocketConnectable(MyHttpApp.class, "ws://localhost:8080/ws").serType(SerializerType.JsonNoRef);
} else {
connectable = new HttpConnectable(MyHttpApp.class, "http://localhost:8080/api").serType(SerializerType.JsonNoRef);
}
connectable.connect((connector, error) -> {
System.out.println("connection lost " + connector);
}).then((res, err) -> {
myApp = (MyHttpApp) res;
myApp.login("dummy", "dummy").then((s, err1) -> {
session = s;
System.out.println("session connected " + session);
session.subscribe((result, e) -> {
count++;
lastBcast.set(System.currentTimeMillis());
});
});
});
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class StatelessServiceClient method main.
public static void main(String[] args) {
if (args == null || args.length == 0) {
// connect with binary encoding
StatelessServiceClient cl = AsActor(StatelessServiceClient.class);
cl.init(new WebSocketConnectable().url("ws://localhost:6667/slservice/v1/bin").serType(SerializerType.FSTSer).actorClass(IStatelessService.class)).then((r, e) -> {
if (e != null) {
Log.Error(StatelessServiceClient.class, (Throwable) e);
}
});
} else {
// connect with json encoding
StatelessServiceClient cl = AsActor(StatelessServiceClient.class);
cl.init(new WebSocketConnectable().url("ws://localhost:6667/slservice/v1/json").serType(SerializerType.JsonNoRef).actorClass(IStatelessService.class)).then((r, e) -> {
if (e != null) {
Log.Error(StatelessServiceClient.class, (Throwable) e);
}
});
}
}
use of org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable in project kontraktor by RuedigerMoeller.
the class TestCrashClose method main.
public static void main(String[] args) {
boolean http = false;
ConnectableActor connectable;
if (!http) {
connectable = new WebSocketConnectable(MyHttpApp.class, "ws://localhost:8080/ws").serType(SerializerType.JsonNoRef);
} else {
connectable = new HttpConnectable(MyHttpApp.class, "http://localhost:8080/api").serType(SerializerType.JsonNoRef);
}
connectable.connect((connector, error) -> {
System.out.println("connection lost " + connector);
}).then((res, err) -> {
MyHttpApp myApp = (MyHttpApp) res;
myApp.login("dummy", "dummy").then((s, err1) -> {
MyHttpAppSession session = s;
System.out.println("session connected " + session);
session.subscribe((result, e) -> {
System.exit(0);
});
});
});
}
Aggregations