4 Annotated Endpoints
来源:互联网 发布:java工厂模式的作用 编辑:程序博客网 时间:2024/05/17 02:40
官网英文参考:
http://docs.oracle.com/javaee/7/tutorial/doc/websocket004.htm#BABFEBGA
中文解析:
下面是一个通过注释方式实现的endpoint:
@ServerEndpoint("/echo")public class EchoEndpoint { @OnMessage public void onMessage(Session session, String msg) { try { session.getBasicRemote().sendText(msg); } catch (IOException e) { ... } }}
注释方式比编码方式实现更加简单,他是自动部署的,通过ServerEndPoint指定了相对路径。也不需要添加一个message handler,因为这个例子是通过 decorator模式,在调用的时候自动注释的Onmessage 方法。
下表列出了在 javax.websocket 包中可用的注释,在handler生命周期中可指定的方法。更多信息查看API
OnOpen
Connection opened
@OnOpenpublic void open(Session session, EndpointConfig conf) { }
OnMessage
Message received
@OnMessagepublic void message(Session session, String msg) { }
OnError
Connection error
@OnErrorpublic void error(Session session, Throwable error) { }
OnClose
Connection closed
@OnClosepublic void close(Session session, CloseReason reason) { }
0 0
- 4 Annotated Endpoints
- endpoints
- endpoints
- The Annotated Gnutella Protocol Specification v0.4
- 1.4. Endpoints
- annotated imagedb
- annotated CMakeFile
- About channels and endpoints
- EndPoints (端点)
- 3.Programmatic Endpoints
- Annotated STL Done
- Annotated controller and requestParam
- semiautomatic annotated tools
- semiautomatic annotated tools
- Mule ESB Endpoints配置摘要
- Mule ESB Endpoints配置摘要
- twisted.internet.endpoints的使用
- Consul K/V Store Endpoints
- Hdu 1907 && Hdu2509 (nim博弈的相反胜况)
- 1408041943-hd-月之数.cpp
- 想法很重要,但是动手更重要,发现问题并且解决问题
- HDU-1002-大数加法
- SEL和IMP
- 4 Annotated Endpoints
- hdu__Lowest bit1196 (二进制的低位输出)
- 5 Sending and Receiving Messages
- eclipse中配置中文JDK API文档
- ccx ndk release
- 从零开始—随机种子的应用
- junit 测试中各种断言用法
- poj 1651 Multiplication Puzzle dp
- unix网络编程卷1 时间获取客户端程序