Skip to content

Commit

Permalink
feat(ping): Add support for keeping session alive with ping
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Lewis committed Aug 24, 2021
1 parent 8d6b1bf commit 64a9c75
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/AppBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ export class AppBridge {
});
}

public ping(): Promise<boolean> {
return new Promise<any>((resolve, reject) => {
if (this._handlers[AppBridgeHandler.PING]) {
this._handlers[AppBridgeHandler.PING]({}, (data: any, error: any) => {
resolve({ data, error });
});
} else {
postRobot.sendToParent(MESSAGE_TYPES.PING, {}).then((event: any) => {
resolve({ data: event.data.data, error: event.data.error });
}).catch((err) => {
reject(null);
});
}
});
}

/**
* Fires or responds to a pin event
*/
Expand Down

0 comments on commit 64a9c75

Please sign in to comment.