本文整理汇总了Java中org.eclipse.jetty.websocket.client.WebSocketClient.stop方法的典型用法代码示例。如果您正苦于以下问题:Java WebSocketClient.stop方法的具体用法?Java WebSocketClient.stop怎么用?Java WebSocketClient.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.websocket.client.WebSocketClient
的用法示例。
在下文中一共展示了WebSocketClient.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: triggerReload
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void triggerReload() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
this.server.triggerReload();
Thread.sleep(500);
this.server.stop();
assertThat(socket.getMessages(0))
.contains("http://livereload.com/protocols/official-7");
assertThat(socket.getMessages(1)).contains("command\":\"reload\"");
}
finally {
client.stop();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:LiveReloadServerTests.java
示例2: connect
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void connect() throws Exception {
final WebSocketClient client = new WebSocketClient();
client.start();
final WebSocketAdapter socket = new WebSocketAdapter() {
@Override
public void onWebSocketConnect(Session session) {
session.getRemote().sendStringByFuture("yo man!");
session.close();
}
};
client.connect(
socket,
URI.create("ws://localhost:8080/ws/"),
new ClientUpgradeRequest()
);
Thread.sleep(1000L);
client.stop();
}
示例3: triggerReload
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void triggerReload() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
this.server.triggerReload();
Thread.sleep(500);
this.server.stop();
assertThat(socket.getMessages(0),
containsString("http://livereload.com/protocols/official-7"));
assertThat(socket.getMessages(1), containsString("command\":\"reload\""));
}
finally {
client.stop();
}
}
示例4: main
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
public static void main(String[] args) {
String destUri = "ws://192.168.100.78:2014";
if (args.length > 0) {
destUri = args[0];
}
WebSocketClient client = new WebSocketClient();
SimpleEchoSocket socket = new SimpleEchoSocket();
try {
client.start();
URI echoUri = new URI(destUri);
ClientUpgradeRequest request = new ClientUpgradeRequest();
client.connect(socket, echoUri, request);
System.out.printf("Connecting to : %s%n", echoUri);
socket.awaitClose(5, TimeUnit.SECONDS);
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
client.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例5: main
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
public static void main(String[] args) {
String destUri = "ws://echo.websocket.org";
if (args.length > 0) {
destUri = args[0];
}
WebSocketClient client = new WebSocketClient();
SimpleEchoSocket socket = new SimpleEchoSocket();
try {
client.start();
URI echoUri = new URI(destUri);
ClientUpgradeRequest request = new ClientUpgradeRequest();
client.connect(socket, echoUri, request);
System.out.printf("Connecting to : %s%n", echoUri);
socket.awaitClose(15, TimeUnit.SECONDS);
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
client.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例6: notifyWebSockets
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
private void notifyWebSockets(final String data) {
URI uri = URI.create("ws://localhost:8080/trades/");
WebSocketClient client = new WebSocketClient();
try {
try {
client.start();
// The socket that receives events
TradeSocket socket = new TradeSocket();
// Attempt Connect
Future<Session> fut = client.connect(socket, uri);
// Wait for Connect
Session session = fut.get();
// Send a message
session.getRemote().sendString(data);
// Close session
session.close();
} finally {
client.stop();
}
} catch (Throwable t) {
//t.printStackTrace(System.err);
}
}
示例7: LOLOLOL
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
public void LOLOLOL(){
System.out.println( "Hello World!" );
String dest = "ws://localhost:8080/jsr356toUpper";
WebSocketClient client = new WebSocketClient();
try {
ToUpperClientSocket socket = new ToUpperClientSocket();
client.start();
URI echoUri = new URI(dest);
ClientUpgradeRequest request = new ClientUpgradeRequest();
client.connect(socket, echoUri, request);
socket.getLatch().await();
ByteBuffer buf = ByteBuffer.allocate(5);
buf.put(0, (byte)254);
buf.order(ByteOrder.LITTLE_ENDIAN);
buf.putInt(1, 5);
socket.sendMessage(buf);
Thread.sleep(10000l);
String name = "BadPlayer";
ByteBuffer buf1 = ByteBuffer.allocate(1 + 2*name.length());
buf1.put(0, (byte)0);
for (int i=0;i<name.length();i++) {
buf1.order(ByteOrder.LITTLE_ENDIAN);
buf.putShort(1 + i*2 ,(short)name.charAt(i));
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
client.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例8: main
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
AppUtil.startLogging(args, 1);
final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("org.eclipse.jetty");
if (!(logger instanceof ch.qos.logback.classic.Logger)) {
return;
}
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) logger;
logbackLogger.setLevel(ch.qos.logback.classic.Level.INFO);
final int serverPort = (args.length > 0) ? Integer.parseInt(args[0]) : DEFAULT_SERVER_PORT;
final String destUri = "ws://localhost:" + Integer.toString(serverPort) + "/test";
final SocketTestServer socketServer = new SocketTestServer();
final SessionHandler sessionHandler = new SimpleSessionHandler(socketServer, new ServletSessionStore());
final RequestHandler handler = new RequestHandler(null, sessionHandler);
final Server server = new Server(serverPort);
final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new EmbeddedServlet(handler)), "/*");
server.start();
System.out.println("Server started");
Thread.sleep(10000);
// Start Client
final WebSocketClient client = new WebSocketClient();
final SocketTestClient socket = new SocketTestClient();
client.start();
final URI uri = new URI(destUri);
final ClientUpgradeRequest request = new ClientUpgradeRequest();
System.out.printf("Connecting to : %s%n", uri);
// wait for closed socket connection.
socket.awaitClose(5,TimeUnit.SECONDS);
client.stop();
}
示例9: pingPong
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void pingPong() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = new Socket();
Driver driver = openSocket(client, new Driver(socket));
socket.getRemote().sendPing(NO_DATA);
Thread.sleep(200);
this.server.stop();
assertThat(driver.getPongCount()).isEqualTo(1);
}
finally {
client.stop();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:LiveReloadServerTests.java
示例10: clientClose
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void clientClose() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
socket.getSession().close();
}
finally {
client.stop();
}
awaitClosedException();
assertThat(this.server.getClosedExceptions().size()).isGreaterThan(0);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:LiveReloadServerTests.java
示例11: serverClose
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void serverClose() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
Thread.sleep(200);
this.server.stop();
Thread.sleep(200);
assertThat(socket.getCloseStatus()).isEqualTo(1006);
}
finally {
client.stop();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:LiveReloadServerTests.java
示例12: pingPong
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void pingPong() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = new Socket();
Driver driver = openSocket(client, new Driver(socket));
socket.getRemote().sendPing(NO_DATA);
Thread.sleep(200);
this.server.stop();
assertThat(driver.getPongCount(), equalTo(1));
}
finally {
client.stop();
}
}
示例13: clientClose
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void clientClose() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
socket.getSession().close();
}
finally {
client.stop();
}
awaitClosedException();
assertThat(this.server.getClosedExceptions().size(), greaterThan(0));
}
示例14: serverClose
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Test
public void serverClose() throws Exception {
WebSocketClient client = new WebSocketClient();
try {
Socket socket = openSocket(client, new Socket());
Thread.sleep(200);
this.server.stop();
Thread.sleep(200);
assertThat(socket.getCloseStatus(), equalTo(1006));
}
finally {
client.stop();
}
}
示例15: run
import org.eclipse.jetty.websocket.client.WebSocketClient; //导入方法依赖的package包/类
@Override
public void run(CommandLine theCommandLine) throws ParseException, Exception {
String target = theCommandLine.getOptionValue("t");
if (isBlank(target) || (!target.startsWith("ws://") && !target.startsWith("wss://"))) {
throw new ParseException("Target (-t) needs to be in the form \"ws://foo\" or \"wss://foo\"");
}
IdDt subsId = new IdDt(theCommandLine.getOptionValue("i"));
WebSocketClient client = new WebSocketClient();
SimpleEchoSocket socket = new SimpleEchoSocket(subsId.getIdPart());
try {
client.start();
URI echoUri = new URI(target);
ClientUpgradeRequest request = new ClientUpgradeRequest();
ourLog.info("Connecting to : {}", echoUri);
client.connect(socket, echoUri, request);
while (!myQuit) {
Thread.sleep(500L);
}
ourLog.info("Shutting down websocket client");
} finally {
try {
client.stop();
} catch (Exception e) {
ourLog.error("Failure", e);
}
}
}