1
1
# RxSocketClient
2
2
3
- [ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( https://github.com/codeestX/RxSocketClient/pulls ) [ ![ API] ( https://img.shields.io/badge/API-20%2B-brightgreen.svg )] ( https://android-arsenal.com/api?level=20 ) [ ![ License] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( https://opensource.org/licenses/Apache-2.0 )
3
+ [ ![ PRs Welcome] ( https://img.shields.io/badge/PRs-welcome-brightgreen.svg )] ( https://github.com/codeestX/RxSocketClient/pulls ) [ ![ API] ( https://img.shields.io/badge/API-20%2B-brightgreen.svg )] ( https://android-arsenal.com/api?level=20 ) [ ![ License] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( https://opensource.org/licenses/Apache-2.0 ) [ ![ ] ( https://jitpack.io/v/codeestX/RxSocketClient.svg )] ( https://jitpack.io/#codeestX/RxSocketClient )
4
4
5
5
RxSocketClient, Reactive Socket APIs for Android, Java and Kotlin, powered by RxJava2
6
6
RxSocketClient,支持Android,Java和Kotlin的响应式Socket APIs封装,基于RxJava2
@@ -9,6 +9,21 @@ RxJava2 Version: 2.1.1
9
9
10
10
# Usage
11
11
12
+ Step 1. Add the JitPack repository to your build file
13
+
14
+ allprojects {
15
+ repositories {
16
+ ...
17
+ maven { url "https://jitpack.io" }
18
+ }
19
+ }
20
+
21
+ Step 2. Add the dependency
22
+
23
+ dependencies {
24
+ compile 'com.github.codeestX:RxSocketClient:v1.0.0'
25
+ }
26
+
12
27
### init
13
28
``` java
14
29
SocketClient mClient = RxSocketClient
@@ -40,33 +55,33 @@ SocketClient mClient = RxSocketClient
40
55
### connect
41
56
``` java
42
57
Disposable ref = mClient. connect()
43
- ... // anything else what you can do with RxJava
58
+ ... // anything else what you can do with RxJava
44
59
.observeOn(AndroidSchedulers . mainThread())
45
60
.subscribe(new SocketSubscriber () {
46
61
@Override
47
62
public void onConnected () {
48
- // onConnected
63
+ // onConnected
49
64
Log . e(TAG , " onConnected" );
50
65
}
51
66
52
67
@Override
53
68
public void onDisconnected () {
54
- // onDisconnected
69
+ // onDisconnected
55
70
Log . e(TAG , " onDisconnected" );
56
71
}
57
72
58
73
@Override
59
74
public void onResponse (@NotNull byte [] data ) {
60
- // receive data
75
+ // receive data
61
76
Log . e(TAG , Arrays . toString(data));
62
77
}
63
78
}, new Consumer<Throwable > () {
64
- @Override
65
- public void accept (Throwable throwable ) throws Exception {
66
- // onError
67
- Log . e(TAG , throwable. toString());
68
- }
69
- });
79
+ @Override
80
+ public void accept (Throwable throwable ) throws Exception {
81
+ // onError
82
+ Log . e(TAG , throwable. toString());
83
+ }
84
+ });
70
85
```
71
86
72
87
### disconnect
0 commit comments