Skip to content

Commit

Permalink
Merge pull request #11 from bullhorn/f/ping
Browse files Browse the repository at this point in the history
feat(ping): Add support for keeping session alive with ping
  • Loading branch information
nickle799 authored Aug 24, 2021
2 parents a1fdd25 + 32de587 commit 8d6b1bf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AppBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export enum AppBridgeHandler {
REGISTER,
UPDATE,
REQUEST_DATA,
CALLBACK
CALLBACK,
PING
}

export type NovoApps = 'record' | 'add' | 'fast-add' | 'custom';
Expand Down Expand Up @@ -53,6 +54,7 @@ const MESSAGE_TYPES = {
CLOSE: 'close',
REFRESH: 'refresh',
PIN: 'pin',
PING: 'ping',
UPDATE: 'update',
HTTP_GET: 'httpGET',
HTTP_POST: 'httpPOST',
Expand Down Expand Up @@ -162,6 +164,13 @@ export class AppBridge {
return { success };
});
});
// PING
postRobot.on(MESSAGE_TYPES.PING, (event) => {
this._trace(MESSAGE_TYPES.PING, event);
return this.httpGET('ping').then(result => {
return { data: result.data, error: result.error };
});
});
// REQUEST_DATA
postRobot.on(MESSAGE_TYPES.REQUEST_DATA, (event) => {
this._trace(MESSAGE_TYPES.REQUEST_DATA, event);
Expand Down

0 comments on commit 8d6b1bf

Please sign in to comment.