本文整理汇总了Java中org.springframework.messaging.simp.stomp.StompSessionHandler类的典型用法代码示例。如果您正苦于以下问题:Java StompSessionHandler类的具体用法?Java StompSessionHandler怎么用?Java StompSessionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StompSessionHandler类属于org.springframework.messaging.simp.stomp包,在下文中一共展示了StompSessionHandler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
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.
}
示例2: main
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
public static void main(String[] args) {
DefaultSetting.setDefaultNetwork();
if(args.length==0){
OutputMessage.error("please enter parameter");
return;
}
Map<String, String> params = parseParamsToMap(args);
if(params==null){
return;
}
// set host, port and websocket port
DefaultSetting.setHostAndPort(params.get("host"), params.get("port"), params.get("wsPort"));
final String address = params.get("address");
final String WS_URI = DefaultSetting.getWsUri();
// create WebSocket client
List<Transport> transports = new ArrayList<Transport>(1);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
WebSocketClient transport = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
stompClient.setMessageConverter(new StringMessageConverter());
StompSessionHandler handler = new WsMonitorMultisigHandler(address);
stompClient.connect(WS_URI, handler);
//block and monitor exit action
ScannerUtil.monitorExit();
}
示例3: main
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
public static void main(String[] args) {
DefaultSetting.setDefaultNetwork();
if(args.length==0){
OutputMessage.error("please enter parameter");
return;
}
Map<String, String> params = parseParamsToMap(args);
if(params==null){
return;
}
// set host, port and websocket port
DefaultSetting.setHostAndPort(params.get("host"), params.get("port"), params.get("wsPort"));
final String address = params.get("address");
final String WS_URI = DefaultSetting.getWsUri();
// create WebSocket client
List<Transport> transports = new ArrayList<Transport>(1);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
WebSocketClient transport = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
stompClient.setMessageConverter(new StringMessageConverter());
StompSessionHandler handler = new WsMonitorImcomingHandler(address);
stompClient.connect(WS_URI, handler);
//block and monitor exit action
ScannerUtil.monitorExit();
}
示例4: main
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception
{
WebSocketClient simpleWebSocketClient =
new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>(1);
transports.add(new WebSocketTransport(simpleWebSocketClient));
SockJsClient sockJsClient = new SockJsClient(transports);
WebSocketStompClient stompClient =
new WebSocketStompClient(sockJsClient);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
String url = "ws://localhost:9090/chat";
String userId = "spring-" +
ThreadLocalRandom.current().nextInt(1, 99);
StompSessionHandler sessionHandler = new MyStompSessionHandler(userId);
StompSession session = stompClient.connect(url, sessionHandler)
.get();
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
for (;;) {
System.out.print(userId + " >> ");
System.out.flush();
String line = in.readLine();
if ( line == null ) break;
if ( line.length() == 0 ) continue;
ClientMessage msg = new ClientMessage(userId, line);
session.send("/app/chat/java", msg);
}
}
示例5: connect
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
private WebSocketHandler connect() {
this.stompClient.connect("/foo", mock(StompSessionHandler.class));
verify(this.stompSession).getSessionFuture();
verifyNoMoreInteractions(this.stompSession);
WebSocketHandler webSocketHandler = this.webSocketHandlerCaptor.getValue();
assertNotNull(webSocketHandler);
return webSocketHandler;
}
示例6: connect
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
public void connect(int port, StompSessionHandler handler) {
connect(port, new WebSocketHttpHeaders(), handler);
}
示例7: createSession
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
@Override
protected ConnectionHandlingStompSession createSession(StompHeaders headers, StompSessionHandler handler) {
return this.stompSession;
}
示例8: connect
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
/**
* 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 URI variables to expand into the URL
* @return ListenableFuture for access to the session when ready for use
*/
public ListenableFuture<StompSession> connect(String url, WebSocketHttpHeaders handshakeHeaders,
StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
Assert.notNull(url, "uriTemplate must not be null");
URI uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).encode().toUri();
return connect(uri, handshakeHeaders, connectHeaders, handler);
}