Skip to content

Commit

Permalink
naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Oberstein committed Jun 22, 2012
1 parent 5fa15c1 commit e6f1e4f
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 148 deletions.
Binary file removed Autobahn/doc/autobahn_logo_doxygen.png
Binary file not shown.
85 changes: 85 additions & 0 deletions Autobahn/src/de/tavendo/autobahn/Doxygen.java
@@ -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 {

}
99 changes: 9 additions & 90 deletions Autobahn/src/de/tavendo/autobahn/Wamp.java
Expand Up @@ -21,98 +21,18 @@

import org.codehaus.jackson.type.TypeReference;

/*!
\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>.
Commercial support and services is available from <a href="http://www.tavendo.de">Tavendo GmbH</a>.
*/

/**
* Autobahn interface.
* WAMP interface.
*/
public interface Wamp {

/**
* Session handler for Autobahn sessions.
* Session handler for WAMP sessions.
*/
public interface SessionHandler {
public interface ConnectionHandler {

/**
* Fired upon successful establishment of connection to Autobahn server.
* Fired upon successful establishment of connection to WAMP server.
*/
public void onOpen();

Expand All @@ -124,30 +44,29 @@ public interface SessionHandler {
* @param reason A humand readable description of the reason of connection close.
*/
public void onClose(int code, String reason);

}

/**
* Connect to Autobahn server.
* Connect to WAMP server.
*
* @param wsUri The WebSockets URI of the server.
* @param sessionHandler The handler for the session.
*/
public void connect(String wsUri, SessionHandler sessionHandler);
public void connect(String wsUri, ConnectionHandler sessionHandler);


/**
* Connect to Autobahn server.
* Connect to WAMP server.
*
* @param wsUri The WebSockets URI of the server.
* @param sessionHandler The handler for the session.
* @param options WebSockets and Autobahn option.s
*/
public void connect(String wsUri, SessionHandler sessionHandler, WampOptions options);
public void connect(String wsUri, ConnectionHandler sessionHandler, WampOptions options);


/**
* Disconnect from Autobahn server.
* Disconnect from WAMP server.
*/
public void disconnect();

Expand Down
10 changes: 5 additions & 5 deletions Autobahn/src/de/tavendo/autobahn/WampConnection.java
Expand Up @@ -106,7 +106,7 @@ public static class SubMeta {
private final ConcurrentHashMap<String, SubMeta> mSubs = new ConcurrentHashMap<String, SubMeta>();

/// The session handler provided to connect().
private Wamp.SessionHandler mSessionHandler;
private Wamp.ConnectionHandler mSessionHandler;


/**
Expand Down Expand Up @@ -159,7 +159,7 @@ private String newId() {
}


public void connect(String wsUri, Wamp.SessionHandler sessionHandler) {
public void connect(String wsUri, Wamp.ConnectionHandler sessionHandler) {

WampOptions options = new WampOptions();
options.setReceiveTextMessagesRaw(true);
Expand All @@ -177,7 +177,7 @@ public void connect(String wsUri, Wamp.SessionHandler sessionHandler) {
* @param wsUri WebSockets server URI.
* @param sessionHandler The session handler to fire callbacks on.
*/
public void connect(String wsUri, Wamp.SessionHandler sessionHandler, WampOptions options) {
public void connect(String wsUri, Wamp.ConnectionHandler sessionHandler, WampOptions options) {

mSessionHandler = sessionHandler;

Expand All @@ -186,7 +186,7 @@ public void connect(String wsUri, Wamp.SessionHandler sessionHandler, WampOption
mOutgoingPrefixes.clear();

try {
connect(wsUri, new String[] {"wamp"}, new WebSocketHandler() {
connect(wsUri, new String[] {"wamp"}, new WebSocketConnectionHandler() {

@Override
public void onOpen() {
Expand All @@ -211,7 +211,7 @@ public void onClose(int code, String reason) {
} catch (WebSocketException e) {

if (mSessionHandler != null) {
mSessionHandler.onClose(WebSocketHandler.CLOSE_CANNOT_CONNECT, "cannot connect (" + e.toString() + ")");
mSessionHandler.onClose(WebSocketConnectionHandler.CLOSE_CANNOT_CONNECT, "cannot connect (" + e.toString() + ")");
} else {
if (DEBUG) Log.d(TAG, "could not call onClose() .. handler already NULL");
}
Expand Down
15 changes: 15 additions & 0 deletions Autobahn/src/de/tavendo/autobahn/WampConnectionHandler.java
@@ -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

}

}
82 changes: 82 additions & 0 deletions Autobahn/src/de/tavendo/autobahn/WebSocket.java
@@ -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);
}

0 comments on commit e6f1e4f

Please sign in to comment.