本文整理汇总了Java中org.springframework.web.socket.sockjs.client.Transport类的典型用法代码示例。如果您正苦于以下问题:Java Transport类的具体用法?Java Transport怎么用?Java Transport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transport类属于org.springframework.web.socket.sockjs.client包,在下文中一共展示了Transport类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的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();
}
示例2: main
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的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();
}
示例3: stompClient
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(WebSocketStompClient.class)
public WebSocketStompClient stompClient(MessageConverter messageConverter,
ThreadPoolTaskScheduler taskScheduler) {
int bufferSizeLimit = 1024 * 1024 * 8;
StandardWebSocketClient webSocketClient = new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(webSocketClient));
SockJsClient sockJsClient = new SockJsClient(transports);
WebSocketStompClient client = new WebSocketStompClient(sockJsClient);
client.setInboundMessageSizeLimit(bufferSizeLimit);
client.setMessageConverter(messageConverter);
client.setTaskScheduler(taskScheduler);
client.setDefaultHeartbeat(new long[]{0, 0});
return client;
}
开发者ID:mthizo247,项目名称:spring-cloud-netflix-zuul-websocket,代码行数:18,代码来源:ZuulWebSocketConfiguration.java
示例4: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
log.info("Setting up Quotes Web Socket Integration test....");
port = SocketUtils.findAvailableTcpPort();
server = new TomcatWebSocketTestServer(port);
server.deployConfig(FrontendWebApplicationInitializer.class);
server.start();
loginAndSaveXAuthToken("harrymitchell", "HarryMitchell5!", headers);
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate());
xhrTransport.setRequestHeaders(headers);
transports.add(xhrTransport);
sockJsClient = new SockJsClient(transports);
sockJsClient.setHttpHeaderNames("X-Auth-Token");
log.info("Setup complete!");
}
示例5: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Before
public void setup() {
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
this.sockJsClient = new SockJsClient(transports);
this.stompClient = new WebSocketStompClient(sockJsClient);
this.stompClient.setMessageConverter(new MappingJackson2MessageConverter());
}
示例6: main
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的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);
}
}
示例7: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Before
public void setup() {
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
this.sockJsClient = new SockJsClient(transports);
this.stompClient = new WebSocketStompClient(sockJsClient);
this.stompClient.setMessageConverter(new MappingJackson2MessageConverter());
}
示例8: run
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Test
public void run() throws Exception {
List<Transport> transports = new ArrayList<Transport>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
SockJsClient sockJsClient = new SockJsClient(transports);
ListenableFuture<WebSocketSession> wsSession = sockJsClient.doHandshake(
this.webSocketHandler, "ws://localhost:" + this.port + "/sockjs");
this.thrown.expect(ExecutionException.class);
wsSession.get().sendMessage(new TextMessage("a"));
}
示例9: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Before
public void setup() {
List<Transport> transports = Arrays.asList(
new WebSocketTransport(new StandardWebSocketClient()),
new RestTemplateXhrTransport(new RestTemplate()));
this.sockJsClient = new SockJsClient(transports);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:WebSocketMessagingAutoConfigurationTests.java
示例10: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
// Since test classpath includes both embedded Tomcat and Jetty we need to
// set a Spring profile explicitly to bypass WebSocket engine detection.
// See {@link org.springframework.samples.portfolio.config.WebSocketConfig}
// This test is not supported with Jetty because it doesn't seem to support
// deployment withspecific ServletContainerInitializer's at for testing
System.setProperty("spring.profiles.active", "test.tomcat");
port = SocketUtils.findAvailableTcpPort();
server = new TomcatWebSocketTestServer(port);
server.deployConfig(TestDispatcherServletInitializer.class, WebSecurityInitializer.class);
server.start();
loginAndSaveJsessionIdCookie("fabrice", "fab123", headers);
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate());
xhrTransport.setRequestHeaders(headers);
transports.add(xhrTransport);
sockJsClient = new SockJsClient(transports);
}
示例11: createWebSocketClient
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Override
protected WebSocketClient createWebSocketClient() {
List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
return new SockJsClient(transports);
}
示例12: run
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@Test
public void run() throws Exception {
List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
SockJsClient sockJsClient = new SockJsClient(transports);
ListenableFuture<WebSocketSession> wsSession = sockJsClient.doHandshake(
this.webSocketHandler, "ws://localhost:" + this.port + "/sockjs");
this.thrown.expect(ExecutionException.class);
wsSession.get().sendMessage(new TextMessage("a"));
}
示例13: createTransportClient
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
private List<Transport> createTransportClient() {
return Collections.singletonList(new WebSocketTransport(new StandardWebSocketClient()));
}
示例14: setup
import org.springframework.web.socket.sockjs.client.Transport; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
System.setProperty("spring.profiles.active", "test.tomcat");
port = SocketUtils.findAvailableTcpPort();
server = new TomcatWebSocketTestServer(port);
server.deployConfig(TestDispatcherServletInitializer.class);
server.start();
webSocketUri = "ws://localhost:" + port + "/composite/websocket";
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
RestTemplateXhrTransport xhrTransport = new RestTemplateXhrTransport(new RestTemplate());
xhrTransport.setRequestHeaders(headers);
transports.add(xhrTransport);
sockJsClient = new SockJsClient(transports);
}