本文整理汇总了Java中javax.websocket.ClientEndpointConfig.Builder.build方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.build方法的具体用法?Java Builder.build怎么用?Java Builder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.websocket.ClientEndpointConfig.Builder
的用法示例。
在下文中一共展示了Builder.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WebsocketClient
import javax.websocket.ClientEndpointConfig.Builder; //导入方法依赖的package包/类
public WebsocketClient(String uri, final String sessionID, MessageHandler.Whole<String> messageHandler)
throws IOException {
// add session ID so the request gets through LAMS security
Builder configBuilder = ClientEndpointConfig.Builder.create();
configBuilder.configurator(new Configurator() {
@Override
public void beforeRequest(Map<String, List<String>> headers) {
headers.put("Cookie", Arrays.asList("JSESSIONID=" + sessionID));
}
});
ClientEndpointConfig clientConfig = configBuilder.build();
this.websocketEndpoint = new WebsocketEndpoint(messageHandler);
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
try {
container.connectToServer(websocketEndpoint, clientConfig, new URI(uri));
} catch (DeploymentException | URISyntaxException e) {
throw new IOException("Error while connecting to websocket server", e);
}
}
示例2: getDefaultConfig
import javax.websocket.ClientEndpointConfig.Builder; //导入方法依赖的package包/类
public static ClientEndpointConfig getDefaultConfig() {
Builder b = ClientEndpointConfig.Builder.create();
return b.build();
}