Giter Club home page Giter Club logo

autobahnandroid's Introduction

AutobahnAndroid

Autobahn|Android is a subproject of the Autobahn project and provides an open-source implementation

for Android.

WebSocket allows bidirectional real-time messaging on the Web.

WAMP provides asynchronous Remote Procedure Calls and Publish & Subscribe for applications in one protocol.

WAMP is ideal for distributed, multi-client and server applications, such as multi-user database-drive business applications, sensor networks (IoT), instant messaging or MMOGs (massively multi-player online games) .

Note: Autobahn|Android implements version 1 of WAMP. Current versions of the other Autobahn project libraries already provide implementations of version 2 of the protocol, with substantially expanded capabilities. An update to Autobahn|Android is under development.

Show me some code

Here is a simple 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());
   }
}

... and a simple WAMP v1 client calling a RPC endpoint and subscribitng to a PubSub topic:

private final AutobahnConnection mConnection = new AutobahnConnection();

private void start() {

   final String wsuri = "ws://localhost:9000";

   mConnection.connect(wsuri, new Autobahn.SessionHandler() {

      @Override
      public void onOpen() {
         testRpc();
         testPubSub();
      }

      @Override
      public void onClose(int code, String reason) {
      }
   });
}

private void testRpc() {

   mConnection.call("http://example.com/calc#add",
                    Integer.class,
                    new Autobahn.CallHandler() {

                        @Override
                        public void onResult(Object result) {
                           int res = (Integer) result;
                           Log.d(TAG, "calc:add result = " + res);
                        }

                        @Override
                        public void onError(String error, String info) {
                        }
                    },
                    23, 55
   );
}

private static class MyEvent1 {
   public int num;
   public String name;
   public boolean flag;
   public Date created;
   public double rand;
}

private void testPubSub() {

   mConnection.subscribe("http://example.com/events#myevent1",
                         MyEvent1.class,
                         new Autobahn.EventHandler() {

                            @Override
                            public void onEvent(String topic, Object event) {

                               MyEvent1 evt = (MyEvent1) event;
                            }
                         }
   );
}

Features

  • library for WebSocket and WAMP clients
  • implements WebSocket RFC6455, Draft Hybi-10+ and WAMP v1
  • works on Android 2.2+
  • very good standards conformance
  • high-performance asynchronous design
  • easy to use API
  • seamless integration in Android UI apps
  • no (really none) network activity on UI thread
  • Open-source (Apache 2 license)

You can use AutobahnAndroid to create native Android apps talking to WebSocket servers or any WAMP compatible server.

More Information

For more information, take a look at the project documentation. This provides:

Get in touch

Get in touch on IRC #autobahn on chat.freenode.net or join the mailing list.

autobahnandroid's People

Contributors

almozavr avatar chrismeyersfsu avatar filipmaelbrancke avatar magnux avatar murph avatar ottoallmendinger avatar william-ferguson-au avatar zerodivisi0n avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.