All Projects → issotina → WebSocketAndroidClient

issotina / WebSocketAndroidClient

Licence: other
Android webSocket client for Ratchet Server

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to WebSocketAndroidClient

python-api
Trading API for Quedex Bitcoin Derivatives Exchange.
Stars: ✭ 20 (+17.65%)
Mutual labels:  autobahn
Ratchet
Build mobile apps with simple HTML, CSS, and JavaScript components.
Stars: ✭ 14,480 (+85076.47%)
Mutual labels:  ratchet
Ratchet
Asynchronous WebSocket server
Stars: ✭ 5,596 (+32817.65%)
Mutual labels:  ratchet
Autobahn Python
WebSocket and WAMP in Python for Twisted and asyncio
Stars: ✭ 2,305 (+13458.82%)
Mutual labels:  autobahn
Autobahn Java
WebSocket & WAMP in Java for Android and Java 8
Stars: ✭ 1,467 (+8529.41%)
Mutual labels:  autobahn
vue-wamp
AutobahnJS wrapper library fo Vue.js
Stars: ✭ 48 (+182.35%)
Mutual labels:  autobahn

WebSocketAndroidClient

Android webSocket client for Ratchet Server

Credit : This android library use Autobahn-java

Installation

1 - Add it in your root build.gradle at the end of repositories:

  allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

2 - Add the dependency

dependencies {
           compile 'com.github.geeckmc:WebSocketAndroidClient:0.0.7'
   }

3 - Add packaging options

android
{
...
 packagingOptions {
       exclude 'META-INF/LICENSE'
       exclude 'META-INF/ASL2.0'
   }
}

Usage

1 - Create an Web Socket Instance and start connection

  Ws ws = new Ws.Builder().from( "ws://server_address");
  ws.connect();

2 - Subscribe to channel

Basically get raw data

        ws.on("path/to/channel", new Ws.WsListner() {
            @Override
            public void onEvent(String eventUri, Object data) {
                if(data != null) //your logic here
            }
        });

OR

Get parsed object from json response, for example to get User from channel do something like this

        ws.on("path/to/channel", User.class, new Ws.WsListner<User>() {
            @Override
            public void onEvent(String eventUri, User user) {
                if(user != null) Log.e(TAG,user.name);
            }
        });

2 - Send data to server

ws.send("Hello World");

or send to specific channel

ws.send("path/to/channel","Hello Channel");

3 - Close Connection and remove listners

 ws.end();

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].