Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tobias Oberstein
committed
Jun 22, 2012
1 parent
5fa15c1
commit e6f1e4f
Showing
13 changed files
with
227 additions
and
148 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package de.tavendo.autobahn; | ||
|
||
/*! | ||
\mainpage | ||
\section intro_sec AutobahnAndroid API Reference | ||
<a href="http://autobahn.ws">AutobahnAndroid</a> provides a Java client library implementing | ||
<a href="http://tools.ietf.org/html/rfc6455">The WebSocket Protocol</a> and | ||
<a href="http://wamp.ws">The WebSocket Application Messaging Protocol</a> for use | ||
in native Android apps. | ||
\section websocket_features WebSocket Support | ||
<a href="http://autobahn.ws">AutobahnAndroid</a> implements the WebSocket protocol | ||
with a couple of distinct features: | ||
\li full RFC6455 and Draft Hybi-10 to -17 support | ||
\li very good <a href="http://autobahn.ws/testsuite/reports/mobileclients/">standards conformance</a> | ||
\li performant | ||
\li easy to use API | ||
\li designed to work with Android UI applications | ||
\li Open-Source, licensed under the Apache 2.0 license | ||
The implementation passes all (nearly 300) tests from the | ||
<a href="http://autobahn.ws/testsuite">AutobahnTestSuite</a>. | ||
The basic API is modeled after the WebSocket JavaScript API for | ||
ease of use and familarity. | ||
The API enables the use of common Android idioms for event handling (using | ||
anonymous inner classes) and integrates with Android UI applications (by | ||
communicating via messages and message loops between the UI thread and back- | ||
ground reader/writer threads and by avoiding _any_ network activity on the | ||
UI thread). | ||
The implementation uses Java NIO to reduce network processing overhead and | ||
is on-par or faster performance-wise compared to Firefox 8 Mobile, a C++ | ||
implementation of WebSockets. | ||
\section rpc_pubsub WAMP (RPC/PubSub) Support | ||
<a href="http://autobahn.ws">AutobahnAndroid</a> also | ||
includes an implementation of <a href="http://wamp.ws">The WebSocket Application Messaging Protocol (WAMP)</a> | ||
which can be used to build applications around <b>Remote Procedure Call</b> and | ||
<b>Publish & Subscribe</b> messaging patterns. | ||
It features: | ||
\li RPC and PubSub, fully asynchronous design | ||
\li built on JSON and WebSockets | ||
\li simple, efficient and open protocol | ||
\li automatic mapping to user-defined POJOs | ||
\li seamless integration in Android UI apps | ||
\li Open-Source, licensed under the Apache 2.0 license | ||
Call results and events which travel the wire as JSON payload are automatically | ||
converted and mapped to Java primitive types or user-defined POJOs (Plain-old Java Objects). | ||
The latter is a very convenient and powerful feature made possible by the use of | ||
<a href="http://jackson.codehaus.org/">Jackson</a>, a high-performance JSON processor. | ||
This works even for container types, such as lists or maps over POJOs. | ||
For example, it is possible to issue a RPC and get a List<Person> as a result, where Person is | ||
a user-defined class. | ||
\section usage Usage | ||
The only dependency of | ||
<a href="http://autobahn.ws">AutobahnAndroid</a> | ||
is <a href="http://jackson.codehaus.org/">Jackson</a>. | ||
To use, all one needs to do is to include the built JARs into an Android | ||
project. | ||
\section more More Information | ||
For more information, please visit the <a href="http://autobahn.ws/android">project page</a>, | ||
the <a href="http://groups.google.com/group/autobahnws">forum</a> or the | ||
<a href="https://github.com/tavendo/AutobahnAndroid">code repository</a>. | ||
*/ | ||
|
||
/// Empty class file to hold Doxygen documentation. | ||
abstract class Doxygen { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Autobahn/src/de/tavendo/autobahn/WampConnectionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.tavendo.autobahn; | ||
|
||
public class WampConnectionHandler implements Wamp.ConnectionHandler { | ||
|
||
public void onOpen() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
public void onClose(int code, String reason) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package de.tavendo.autobahn; | ||
|
||
public interface WebSocket { | ||
|
||
/** | ||
* Session handler for WebSocket sessions. | ||
*/ | ||
public interface ConnectionHandler { | ||
|
||
/** | ||
* Connection was closed normally. | ||
*/ | ||
public static final int CLOSE_NORMAL = 1; | ||
|
||
/** | ||
* Connection could not be established in the first place. | ||
*/ | ||
public static final int CLOSE_CANNOT_CONNECT = 2; | ||
|
||
/** | ||
* A previously established connection was lost unexpected. | ||
*/ | ||
public static final int CLOSE_CONNECTION_LOST = 3; | ||
|
||
/** | ||
* The connection was closed because a protocol violation | ||
* occurred. | ||
*/ | ||
public static final int CLOSE_PROTOCOL_ERROR = 4; | ||
|
||
/** | ||
* Internal error. | ||
*/ | ||
public static final int CLOSE_INTERNAL_ERROR = 5; | ||
|
||
/** | ||
* Fired when the WebSockets connection has been established. | ||
* After this happened, messages may be sent. | ||
*/ | ||
public void onOpen(); | ||
|
||
/** | ||
* Fired when the WebSockets connection has deceased (or could | ||
* not established in the first place). | ||
* | ||
* @param code Close code. | ||
* @param reason Close reason (human-readable). | ||
*/ | ||
public void onClose(int code, String reason); | ||
|
||
/** | ||
* Fired when a text message has been received (and text | ||
* messages are not set to be received raw). | ||
* | ||
* @param payload Text message payload or null (empty payload). | ||
*/ | ||
public void onTextMessage(String payload); | ||
|
||
/** | ||
* Fired when a text message has been received (and text | ||
* messages are set to be received raw). | ||
* | ||
* @param payload Text message payload as raw UTF-8 or null (empty payload). | ||
*/ | ||
public void onRawTextMessage(byte[] payload); | ||
|
||
/** | ||
* Fired when a binary message has been received. | ||
* | ||
* @param payload Binar message payload or null (empty payload). | ||
*/ | ||
public void onBinaryMessage(byte[] payload); | ||
} | ||
|
||
public void connect(String wsUri, ConnectionHandler wsHandler) throws WebSocketException; | ||
public void connect(String wsUri, ConnectionHandler wsHandler, WebSocketOptions options) throws WebSocketException; | ||
public void disconnect(); | ||
public boolean isConnected(); | ||
public void sendBinaryMessage(byte[] payload); | ||
public void sendRawTextMessage(byte[] payload); | ||
public void sendTextMessage(String payload); | ||
} |
Oops, something went wrong.