本文整理汇总了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.
}
开发者ID:nielsutrecht,项目名称:spring-boot-websocket-client,代码行数:13,代码来源:ServiceClient.java
示例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();
}
开发者ID:NEMChina,项目名称:nem-apps,代码行数:26,代码来源:ImplMonitorMultisigTransaction.java
示例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();
}
开发者ID:NEMChina,项目名称:nem-apps,代码行数:26,代码来源:ImplMonitorIncomingTransaction.java
示例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);
}
}
开发者ID:jaysridhar,项目名称:spring-websocket-client,代码行数:31,代码来源:Application.java
示例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;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:WebSocketStompClientTests.java
示例6: connect
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
public void connect(int port, StompSessionHandler handler) {
connect(port, new WebSocketHttpHeaders(), handler);
}
开发者ID:borysfan,项目名称:websocket-poc,代码行数:4,代码来源:PersonWebSocketClient.java
示例7: createSession
import org.springframework.messaging.simp.stomp.StompSessionHandler; //导入依赖的package包/类
@Override
protected ConnectionHandlingStompSession createSession(StompHeaders headers, StompSessionHandler handler) {
return this.stompSession;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:WebSocketStompClientTests.java
示例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);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:WebSocketStompClient.java
注:本文中的org.springframework.messaging.simp.stomp.StompSessionHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论