资源简介
代码片段和文件信息
package org.glassfish.tyrus.sample.echo;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.websocket.ContainerProvider;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
/**
* @author Copyright (c) 2013 2014 Oracle and/or its
* affiliates. All rights reserved.
*/
public class Client {
/**
* Runs this example from the command line. Example:
*
* java Client “localhost:7001“
*
* The parameter is the address and port of the WebSocket endpoint server
* It‘s optional and if don‘t supplied it will use “localhost:7001“ instead.
*
*
* @param args URL such as “localhost:7001“ of Server
*/
public static void main(String[] args) {
URI wsUri = null;
try {
if (args.length > 0) {
wsUri = new URI(“ws://“ + args[0] + “/sample-echo/echo“);
} else {
wsUri = new URI(“ws://127.0.0.1:8080/sample-echo/echo“);
}
} catch (URISyntaxException e) {
System.out.println(“Syntax error in your URI!“);
return;
}
try {
//used for hold the client until it received from Server
final CountDownLatch messageLatch = new CountDownLatch(2);
ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() {
@Override
public void onOpen(Session session EndpointConfig config) {
try {
System.out.println(“Connected“);
session.addMessageHandler(new MessageHandler.Whole() {
@Override
public void onMessage(String message) {
System.out.println(“RECEIVED: “ + message);
messageLatch.countDown();
}
});
String strHello = “SENT: hello from Java client“;
System.out.println(strHello);
session.getBasicRemote().sendText(strHello);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onClose(Session session CloseReason closeReason) {
System.out.println(“Closed for “ + closeReason.toString());
}
@Override
public void onerror(Session session Throwable thr) {
System.out.println(“Error occurred:“);
thr.printStackTrace();
}
} ClientEndpointConfig.Builder.create().build() wsUri);
messageLatch.await(1000 TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-08-12 22:22 websocket\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\
文件 1093 2014-08-12 22:30 websocket\weblogic-websocket\.classpath
文件 1343 2014-08-12 14:30 websocket\weblogic-websocket\.project
目录 0 2014-08-12 22:30 websocket\weblogic-websocket\.settings\
文件 522 2014-08-12 14:26 websocket\weblogic-websocket\.settings\.jsdtscope
文件 76 2014-08-12 22:30 websocket\weblogic-websocket\.settings\com.genuitec.eclipse.migration.prefs
文件 364 2014-08-12 14:26 websocket\weblogic-websocket\.settings\org.eclipse.jdt.core.prefs
文件 515 2014-08-12 14:26 websocket\weblogic-websocket\.settings\org.eclipse.wst.common.component
文件 414 2014-08-12 22:30 websocket\weblogic-websocket\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-08-12 14:26 websocket\weblogic-websocket\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-08-12 14:26 websocket\weblogic-websocket\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\org\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\org\glassfish\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\org\glassfish\tyrus\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\org\glassfish\tyrus\sample\
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\src\org\glassfish\tyrus\sample\echo\
文件 3011 2014-08-12 15:15 websocket\weblogic-websocket\src\org\glassfish\tyrus\sample\echo\Client.java
文件 3018 2014-08-12 17:07 websocket\weblogic-websocket\src\org\glassfish\tyrus\sample\echo\EchoEndpoint.java
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\WebRoot\
文件 8562 2014-08-12 14:45 websocket\weblogic-websocket\WebRoot\HTML5_Logo_512.png
文件 4906 2014-08-12 16:25 websocket\weblogic-websocket\WebRoot\index.html
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\WebRoot\me
文件 39 2014-08-12 14:26 websocket\weblogic-websocket\WebRoot\me
文件 6144 2014-08-12 15:06 websocket\weblogic-websocket\WebRoot\Thumbs.db
目录 0 2014-08-12 22:22 websocket\weblogic-websocket\WebRoot\WEB-INF\
目录 0 2014-08-12 22:30 websocket\weblogic-websocket\WebRoot\WEB-INF\classes\
目录 0 2014-08-12 22:30 websocket\weblogic-websocket\WebRoot\WEB-INF\classes\org\
目录 0 2014-08-12 22:30 websocket\weblogic-websocket\WebRoot\WEB-INF\classes\org\glassfish\
目录 0 2014-08-12 22:30 websocket\weblogic-websocket\WebRoot\WEB-INF\classes\org\glassfish\tyrus\
............此处省略214个文件信息
- 上一篇:基于STC89C52单片机智能温控风扇设计资料
- 下一篇:apm飞控源代码
相关资源
- weblogic运维手册
- websocket
- 基于spring websocket实现广播及点对点推
- tomcat实现websocket聊天室
- 叫号语音平台源码
- springboot+websocket实现聊天室
- pinpoint安装部署、监控tomcat、weblogic、
- 用okhttp实现webSocket长连接
- node.js+socket.io+websocket使用demo
- websocket 1V1聊天室
- 简单的在线聊天室实现群聊和单聊,
- e语言-58自动回复招聘方源码 websocke
- libwebsockets-master
- Weblogic密码破解工具V1.0
- skyline技术资料大全(含)
- Springboot多连接池+websocket
- SuperWebSocket使用
- UVM实战
- libwebsockets-master.rar
- websocket实现单聊和群聊
- websocket服务端与客户端通信
- WEB在线聊天系统源码
- HTTP使用WEBLOGIC修改为HTTPS协议
- websocket向指定用户发信息
- Spring Boot整合websocket实现群聊,点对点
- mod_wl_24.so
- 基于vs2010做的tcp通信调试工具源码
- DSP示例代码253710
- 联动北方-企业级IT运维宝典之WebLogi
- Web网盘,WebSocket通讯
评论
共有 条评论