Skip to content

Commit df2a2a4

Browse files
committed
Add getStatus
1 parent 7c25def commit df2a2a4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

android/app/src/main/java/betaflight/configurator/plugin/SocketPlugin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ public void disconnect(final PluginCall call) {
203203
});
204204
}
205205

206+
@PluginMethod
207+
public void getStatus(final PluginCall call) {
208+
JSObject result = new JSObject();
209+
result.put("connected", state.get() == ConnectionState.CONNECTED);
210+
result.put("state", state.get().toString());
211+
call.resolve(result);
212+
}
213+
206214
@Override
207215
protected void handleOnDestroy() {
208216
socketLock.lock();

capacitor-plugin-socket/src/definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export interface SocketPlugin {
33
send(options: { data: string }): Promise<{ success: boolean }>;
44
receive(): Promise<{ data: string }>;
55
disconnect(): Promise<{ success: boolean }>;
6+
getStatus(): Promise<{ connected: boolean, state: string }>;
67
}

0 commit comments

Comments
 (0)