chore: update version to 1.4.3, enhance printing service, and add MyTcpSocket module
This commit is contained in:
@@ -93,7 +93,7 @@ android {
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.4.2"
|
||||
versionName "1.4.3"
|
||||
}
|
||||
signingConfigs {
|
||||
debug {
|
||||
|
||||
@@ -25,6 +25,7 @@ class MainApplication : Application(), ReactApplication {
|
||||
val packages = PackageList(this).packages
|
||||
packages.add(PdfToBitmapPackage())
|
||||
packages.add(TcpSocketPackage())
|
||||
packages.add(MyTcpSocketPackage())
|
||||
return packages
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.anonymous.Assemblr;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.List;
|
||||
|
||||
public class MyTcpSocketModule extends ReactContextBaseJavaModule {
|
||||
public MyTcpSocketModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MyTcpSocket";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void writeToSocket(String ip, int port, ReadableArray data, Promise promise) {
|
||||
try (Socket socket = new Socket(ip, port)) {
|
||||
OutputStream output = socket.getOutputStream();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
String item = data.getString(i);
|
||||
assert item != null;
|
||||
output.write(item.getBytes());
|
||||
}
|
||||
output.flush();
|
||||
promise.resolve("ok");
|
||||
} catch (IOException e) {
|
||||
promise.reject("ERROR", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.anonymous.Assemblr;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MyTcpSocketPackage implements ReactPackage {
|
||||
@NonNull
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
modules.add(new MyTcpSocketModule(reactContext));
|
||||
return modules;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user