本文整理汇总了Java中ws.wamp.jawampa.WampClientBuilder类的典型用法代码示例。如果您正苦于以下问题:Java WampClientBuilder类的具体用法?Java WampClientBuilder怎么用?Java WampClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WampClientBuilder类属于ws.wamp.jawampa包,在下文中一共展示了WampClientBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SignalsWAMPDispatcher
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
/**
* CONSTRUCTOR
*
* @param logger
* @param address
* @throws MalformedURLException
*/
public SignalsWAMPDispatcher(IGlobalLogger logger) {
super();
this.logger = logger;
WampClientBuilder builder = new WampClientBuilder();
try {
IWampConnectorProvider connectorProvider = new NettyWampClientConnectorProvider();
builder.withConnectorProvider(connectorProvider)
.withUri(url)
.withRealm(realm)
.withInfiniteReconnects()
.withReconnectInterval(3, TimeUnit.SECONDS);
client = builder.build();
} catch (Exception e) {
e.printStackTrace();
return;
}
client.open();
}
示例2: SchedulesWAMPDispatcher
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
/**
* CONSTRUCTOR
*
* @param logger
* @param address
* @throws MalformedURLException
*/
public SchedulesWAMPDispatcher(IGlobalLogger logger) {
super();
this.logger = logger;
WampClientBuilder builder = new WampClientBuilder();
try {
IWampConnectorProvider connectorProvider = new NettyWampClientConnectorProvider();
builder.withConnectorProvider(connectorProvider)
.withUri(url)
.withRealm(realm)
.withInfiniteReconnects()
.withReconnectInterval(3, TimeUnit.SECONDS);
client = builder.build();
} catch (Exception e) {
e.printStackTrace();
return;
}
client.open();
}
示例3: init
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
public void init() throws Exception {
WampClientBuilder builder = new WampClientBuilder();
builder.withConnectorProvider(new NettyWampClientConnectorProvider())
.withAuthId(config.wampUsername())
.withAuthMethod(new Ticket(config.wampPassword()))
.withUri(config.wampUri())
.withRealm(config.wampRealm())
.withInfiniteReconnects()
.withReconnectInterval(config.wampReconnectInterval(),
TimeUnit.SECONDS);
client = builder.build();
client.open();
client.statusChanged().subscribe((WampClient.State newStatus) -> {
if (newStatus instanceof WampClient.ConnectedState) {
logger.info("Connected to {}",
config.wampUri());
} else if (newStatus instanceof WampClient.DisconnectedState) {
logger.info("Disconnected from {}",
config.wampUri());
} else if (newStatus instanceof WampClient.ConnectingState) {
logger.debug("Connecting to {}",
config.wampUri());
}
});
}
示例4: init
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
public Observable<WampClient.State> init(
String wampUri, String wampRealm, int wampReconnectInterval,
String authId, String ticket)
throws Exception {
WampClientBuilder builder = new WampClientBuilder();
builder.withConnectorProvider(new PlainWampClientConnectorProvider())
.withUri(wampUri)
.withRealm(wampRealm)
.withInfiniteReconnects()
.withReconnectInterval(wampReconnectInterval,
TimeUnit.SECONDS)
.withAuthId(authId)
.withAuthMethod(new Ticket(ticket));
client = builder.build();
client.open();
return client.statusChanged();
}
示例5: init
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
@Override
public void init() {
try {
WampClientBuilder builder = new WampClientBuilder();
builder.witUri(serverURI)
.withRealm(realm)
.withSslContext(SslContext.newClientContext(
InsecureTrustManagerFactory.INSTANCE))
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
client = builder.build();
client.statusChanged().subscribe((WampClient.Status newStatus) -> {
if(WampClient.Status.Connected == newStatus) {
logger.debug("Connected to WAMP router [{}]", serverURI);
} else if(WampClient.Status.Connecting == newStatus) {
logger.debug("Connecting to WAMP router [{}]", serverURI);
}
});
client.open();
} catch(Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
示例6: getOrCreateClient
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
private CompletableFuture<WampClient> getOrCreateClient(final StreamURI streamURI)
throws ApplicationError {
CompletableFuture<WampClient> result = new CompletableFuture<>();
if (!clients.containsKey(streamURI.getServerURI())) {
WampClientBuilder builder = new WampClientBuilder();
builder.witUri(streamURI.getServerURI().toASCIIString())
.withRealm(DEFAULT_REALM)
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
WampClient client = builder.build();
client.statusChanged().subscribe((WampClient.Status newStatus) -> {
logger.debug("WAMP router [{}] status: {}",
streamURI.getServerURI(), newStatus);
if(newStatus == WampClient.Status.Connected) {
result.complete(client);
}
});
client.open();
clients.put(streamURI.getServerURI(), client);
} else {
result.complete(clients.get(streamURI.getServerURI()));
}
return result;
}
示例7: WSSClient
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
public WSSClient(String uri, String realm) throws ApplicationError, Exception
{
this.subscriptions = new HashMap<>();
WampClientBuilder builder = new WampClientBuilder();
builder.withConnectorProvider(new NettyWampClientConnectorProvider())
.withUri(uri)
.withRealm(realm)
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
wampClient = builder.build();
}
示例8: init
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
public Observable<WampClient.State> init() throws Exception {
WampClientBuilder builder = new WampClientBuilder();
builder.withUri(CONFIG.wampUri()).withRealm(CONFIG.wampRealm())
.withInfiniteReconnects()
.withReconnectInterval(CONFIG.wampReconnectInterval(), TimeUnit.SECONDS)
.withConnectorProvider(new PlainWampClientConnectorProvider())
.withAuthId(CONFIG.wampLogin())
.withAuthMethod(new Ticket(CONFIG.wampPassword()));
client = builder.build();
client.open();
return client.statusChanged();
}
示例9: init
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
@PostConstruct
public void init() {
logger.info("initializing");
final IWampConnectorProvider provider = new NettyWampClientConnectorProvider();
try {
WampClientBuilder builder = new WampClientBuilder();
builder
.withConnectorProvider(provider)
.withUri(config.wampUri())
.withRealm(config.wampRealm())
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
client = builder.build();
client.statusChanged().subscribe((WampClient.State state) -> {
if (state instanceof WampClient.ConnectedState) {
logger.info("connected to WAMP router [{}]", client.routerUri().toASCIIString());
subject.onNext(client);
} else if (state instanceof WampClient.ConnectingState) {
logger.info("connecting to WAMP router [{}]", client.routerUri().toASCIIString());
} else if (state instanceof WampClient.DisconnectedState) {
logger.info("disconnected from WAMP router [{}]", client.routerUri().toASCIIString());
}
});
client.open();
} catch (Exception ex) {
logger.warn(ex.getMessage(), ex);
}
}
示例10: configureWampClient
import ws.wamp.jawampa.WampClientBuilder; //导入依赖的package包/类
private WampClient configureWampClient(WampRouter wampRouter)
{
try {
WampClient wampClient = new WampClientBuilder()
.withRealm(WAMP_REALM)
.withUri(INTERNAL_CLIENT_URI)
.withConnectorProvider(new InMemoryConnectorProvider(wampRouter))
.build();
wampClient.open();
return wampClient;
}catch (Exception e) {
throw new RuntimeException(e);
}
}