本文整理了Java中org.springframework.web.socket.messaging.WebSocketStompClient.connect()
方法的一些代码示例,展示了WebSocketStompClient.connect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebSocketStompClient.connect()
方法的具体详情如下:
包路径:org.springframework.web.socket.messaging.WebSocketStompClient
类名称:WebSocketStompClient
方法名:connect
[英]Connect to the given WebSocket URL and notify the given org.springframework.messaging.simp.stomp.StompSessionHandlerwhen connected on the STOMP level after the CONNECTED frame is received.
[中]连接到给定的WebSocket URL并通知给定的组织。springframework。信息。辛普。跺脚StompSessionHandler在收到连接的帧后在STOMP级别上连接时。
代码示例来源:origin: spring-projects/spring-framework
/**
* Connect to the given WebSocket URL and notify the given
* {@link org.springframework.messaging.simp.stomp.StompSessionHandler}
* when connected on the STOMP level after the CONNECTED frame is received.
* @param url the url to connect to
* @param handler the session handler
* @param uriVars the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, StompSessionHandler handler, Object... uriVars) {
return connect(url, null, handler, uriVars);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
StompSessionHandler handler, Object... uriVariables) {
return connect(url, handshakeHeaders, null, handler, uriVariables);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
* @param handshakeHeaders headers for the WebSocket handshake
* @param connectHeaders headers for the STOMP CONNECT frame
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
@Nullable StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
Assert.notNull(url, "'url' must not be null");
URI uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).encode().toUri();
return connect(uri, handshakeHeaders, connectHeaders, handler);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void publishSubscribe() throws Exception {
String url = "ws://127.0.0.1:" + this.server.getPort() + "/stomp";
TestHandler testHandler = new TestHandler("/topic/foo", "payload");
this.stompClient.connect(url, testHandler);
assertTrue(testHandler.awaitForMessageCount(1, 5000));
assertThat(testHandler.getReceived(), containsInAnyOrder("payload"));
}
代码示例来源:origin: spring-projects/spring-integration
@Override
protected ListenableFuture<StompSession> doConnect(StompSessionHandler handler) {
return ((WebSocketStompClient) this.stompClient).connect(this.url, this.handshakeHeaders, getConnectHeaders(),
handler, this.uriVariables);
}
代码示例来源:origin: org.springframework/spring-websocket
/**
* Connect to the given WebSocket URL and notify the given
* {@link org.springframework.messaging.simp.stomp.StompSessionHandler}
* when connected on the STOMP level after the CONNECTED frame is received.
* @param url the url to connect to
* @param handler the session handler
* @param uriVars the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, StompSessionHandler handler, Object... uriVars) {
return connect(url, null, handler, uriVars);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Connect to the given WebSocket URL and notify the given
* {@link org.springframework.messaging.simp.stomp.StompSessionHandler}
* when connected on the STOMP level after the CONNECTED frame is received.
* @param url the url to connect to
* @param handler the session handler
* @param uriVars the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, StompSessionHandler handler, Object... uriVars) {
return connect(url, null, handler, uriVars);
}
代码示例来源:origin: org.springframework/spring-websocket
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
StompSessionHandler handler, Object... uriVariables) {
return connect(url, handshakeHeaders, null, handler, uriVariables);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
StompSessionHandler handler, Object... uriVariables) {
return connect(url, handshakeHeaders, null, handler, uriVariables);
}
代码示例来源:origin: mthizo247/spring-cloud-netflix-zuul-websocket
public void connect() {
try {
serverSession = stompClient
.connect(getUri().toString(), buildWebSocketHttpHeaders(), this)
.get();
} catch (Exception e) {
logger.error("Error connecting to web socket uri " + getUri(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
* @param handshakeHeaders headers for the WebSocket handshake
* @param connectHeaders headers for the STOMP CONNECT frame
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
@Nullable StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
Assert.notNull(url, "'url' must not be null");
URI uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).encode().toUri();
return connect(uri, handshakeHeaders, connectHeaders, handler);
}
代码示例来源:origin: org.springframework/spring-websocket
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
* @param handshakeHeaders headers for the WebSocket handshake
* @param connectHeaders headers for the STOMP CONNECT frame
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
@Nullable StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
Assert.notNull(url, "'url' must not be null");
URI uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).encode().toUri();
return connect(uri, handshakeHeaders, connectHeaders, handler);
}
代码示例来源:origin: stackoverflow.com
WebSocketClient transport = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
stompClient.setMessageConverter(converter);
StompSessionHandler handler = new WSClient(); //custom implementation
String url = "ws://{URL}/ws/websocket";
stompClient.connect(url, handler);
代码示例来源:origin: CaledoniaProject/CVE-2018-1270
public static void main(String... argv) {
WebSocketClient webSocketClient = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
stompClient.setTaskScheduler(new ConcurrentTaskScheduler());
String url = "ws://127.0.0.1:8080/hello";
StompSessionHandler sessionHandler = new MySessionHandler();
stompClient.connect(url, sessionHandler);
new Scanner(System.in).nextLine(); //Don't close immediately.
}
}
内容来源于网络,如有侵权,请联系作者删除!