Skip to content

Commit 96c02f3

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 907a032 + e34939d commit 96c02f3

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# WebSocketAndroidClient
2+
#### Android webSocket client for [Ratchet Server](http://socketo.me/)
3+
Credit : This android library use [Autobahn-java](https://github.com/crossbario/autobahn-java)
4+
5+
## Installation
6+
### 1 - Add it in your root build.gradle at the end of repositories:
7+
```groovy
8+
9+
allprojects {
10+
repositories {
11+
...
12+
maven { url 'https://jitpack.io' }
13+
}
14+
}
15+
```
16+
### 2 - Add the dependency
17+
```groovy
18+
dependencies {
19+
compile 'com.github.geeckmc:WebSocketAndroidClient:0.0.1'
20+
}
21+
```
22+
23+
### 3 - Add packaging options
24+
```groovy
25+
android
26+
{
27+
...
28+
packagingOptions {
29+
exclude 'META-INF/LICENSE'
30+
exclude 'META-INF/ASL2.0'
31+
}
32+
}
33+
```
34+
35+
## Usage
36+
### 1 - Create an Web Socket Instance and start connection
37+
38+
```java
39+
 Ws ws = new Ws.Builder().from( "ws://server_address");
40+
ws.connect();
41+
```
42+
43+
### 2 - Subscribe to channel
44+
45+
Basically get raw data
46+
```java
47+
ws.on("path/to/channel", new Ws.WsListner() {
48+
@Override
49+
public void onEvent(String eventUri, Object data) {
50+
if(data != null) //your logic here
51+
}
52+
});
53+
```
54+
#### OR
55+
56+
Get parsed object from json response,
57+
for example to get User from channel do something like this
58+
59+
```java
60+
61+
ws.on("path/to/channel", User.class, new Ws.WsListner<User>() {
62+
@Override
63+
public void onEvent(String eventUri, User user) {
64+
if(user != null) Log.e(TAG,user.name);
65+
}
66+
       });
67+
```
68+
69+
License
70+
-------
71+
72+
Licensed under the Apache License, Version 2.0 (the "License");
73+
you may not use this file except in compliance with the License.
74+
You may obtain a copy of the License at
75+
76+
http://www.apache.org/licenses/LICENSE-2.0
77+
78+
Unless required by applicable law or agreed to in writing, software
79+
distributed under the License is distributed on an "AS IS" BASIS,
80+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81+
See the License for the specific language governing permissions and
82+
limitations under the License.

0 commit comments

Comments
 (0)