Skip to content

Commit

Permalink
refactor(plugin): add default protocol in free message service
Browse files Browse the repository at this point in the history
  • Loading branch information
matey97 committed Jul 8, 2022
1 parent 9a7063a commit cfcd8bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions demo/app/home/device-list/device-list-view-model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Observable } from "@nativescript/core";
import { getLogger } from "~/home/logger/logger-view-model";
import { getNodeDiscoverer } from "nativescript-wearos-sensors/node";
import { getFreeMessageClient } from "nativescript-wearos-sensors/internal/communication/free-message";

export class DeviceListViewModel extends Observable {

Expand All @@ -13,6 +14,10 @@ export class DeviceListViewModel extends Observable {
this.logger = getLogger();
this.scanning = false;
this.nodes = [];

getFreeMessageClient().registerListener((receivedMessage) => {
this.logger.logInfo(`received single message ${JSON.stringify(receivedMessage)}`);
});
}

getNode(index: number): ConnectedNode {
Expand Down
3 changes: 0 additions & 3 deletions demo/app/home/device/device-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ export class DeviceViewModel extends Observable {
});

this.freeMessageClient = getFreeMessageClient();
this.freeMessageClient.registerListener((receivedMessage) => {
this.logger.logResultForNode(this.node.name, `received single message ${JSON.stringify(receivedMessage)}`);
});
}

async onTestFreeMessage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { CommunicationResultService } from "../../communication-result-service";
import WearableListenerServiceDelegate = es.uji.geotec.wearos_sensors.messaging.WearableListenerServiceDelegate;
import { FreeMessage, FreeMessageListener, FreeMessageProtocol, ReceivedMessage } from "../index";
import { FreeMessage, FreeMessageListener, freeMessageProtocol, FreeMessageProtocol, ReceivedMessage } from "../index";
import { CommunicationProtocol } from "../../communication-protocol";
import { wearOS } from "../../../utils/android/wear-os-types.android";
import { decodeMessage } from "../../encoder-decoder";
import { decodeFreeMessage } from "../encoder-decoder";

export class FreeMessageResultService implements CommunicationResultService, WearableListenerServiceDelegate {

private protocol: FreeMessageProtocol;
private protocol: FreeMessageProtocol = freeMessageProtocol;
private resolutionCallbacks = new Map<string, FreeMessageListener>();
private defaultListener: FreeMessageListener;

Expand Down

0 comments on commit cfcd8bf

Please sign in to comment.