AutobahnAndroid:实现WebSocket和WAMP协议的开源Android网络类库
jopen
11年前
AutobahnAndroid是一个开源的网络类库用于Java/Android应用。实现了 The WebSocket Protocol 和The WebSocket Application Messaging Protocol (WAMP)协议。
特性:- 支持WebSocket RFC6455, Draft Hybi-10+ 和WAMP v1
- 适用于 Android 2.2+
- 很好的符合标准
- 高性能异步设计
- 易于使用的API
- 与Android UI应用程序无缝集成
- no (really none) network activity on UI thread
- Open-source (Apache 2 license)
WebSocket Echo Client private final WebSocketConnection mConnection = new WebSocketConnection(); private void start() { final String wsuri = "ws://localhost:9000"; try { mConnection.connect(wsuri, new WebSocketHandler() { @Override public void onOpen() { Log.d(TAG, "Status: Connected to " + wsuri); mConnection.sendTextMessage("Hello, world!"); } @Override public void onTextMessage(String payload) { Log.d(TAG, "Got echo: " + payload); } @Override public void onClose(int code, String reason) { Log.d(TAG, "Connection lost."); } }); } catch (WebSocketException e) { Log.d(TAG, e.toString()); } }