Skip to content

Commit

Permalink
feat: release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
codeestX committed Jul 11, 2017
1 parent 1259ecb commit 40fb72c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,33 @@ SocketClient mClient = RxSocketClient
### connect
```java
Disposable ref = mClient.connect()
... // anything else what you can do with RxJava
... // anything else what you can do with RxJava
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SocketSubscriber() {
@Override
public void onConnected() {
//onConnected
Log.e(TAG, "onConnected");
}

@Override
public void onDisconnected() {
//onDisconnected
Log.e(TAG, "onDisconnected");
}

@Override
public void onResponse(@NotNull byte[] data) {
// receive data
//receive data
Log.e(TAG, Arrays.toString(data));
}
});
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
//onError
Log.e(TAG, throwable.toString());
}
});
```

### disconnect
Expand Down
5 changes: 5 additions & 0 deletions RxSocketClient/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'

// JitPack Maven
apply plugin: 'com.github.dcendents.android-maven'
// Group
group='com.github.codeestX'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ class SocketClient(val mConfig: SocketConfig) {
fun sendData(string: String) {
sendData(string.toByteArray(charset = mConfig.mCharset))
}

fun isConnecting(): Boolean {
return mSocket.isConnected
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/moe/codeest/rxsocketclientdemo/JavaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import kotlin.text.Charsets;
import moe.codeest.rxsocketclient.RxSocketClient;
import moe.codeest.rxsocketclient.SocketClient;
Expand Down Expand Up @@ -81,21 +82,30 @@ private void connect() {
.subscribe(new SocketSubscriber() {
@Override
public void onConnected() {
//onConnected
Log.e(TAG, "onConnected");
}

@Override
public void onDisconnected() {
//onDisconnected
Log.e(TAG, "onDisconnected");
//re-connect
// connect();
}

@Override
public void onResponse(@NotNull byte[] data) {
//receive data
Log.e(TAG, Arrays.toString(data));
tvReceive.setText(Arrays.toString(data));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
//onError
Log.e(TAG, throwable.toString());
}
});
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 40fb72c

Please sign in to comment.