-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
511 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SerDe } from "./http"; | ||
|
||
/** | ||
* A SerDe (serializer/deserializer) that uses JSON.stringify and JSON.parse. | ||
* WARNING: this is not secure so should only be used for testing. | ||
*/ | ||
export class JsonSerDe implements SerDe { | ||
serialize<T>(obj: T): Promise<string> { | ||
return Promise.resolve(JSON.stringify(obj)); | ||
} | ||
|
||
deserialize<T>(data: string): Promise<T> { | ||
return Promise.resolve(JSON.parse(data) as T); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
export type SubscriberFunction<T> = (data: T) => void; | ||
|
||
export type SubscriberId = string; | ||
|
||
export interface Subscriber { | ||
subscribe<T>(topic: string, subscriber: SubscriberFunction<T>): Promise<string>; | ||
unsubscribe(topic: string, subscriberId: string): Promise<void>; | ||
subscribe<T extends { type: string }>(topic: string, subscriber: SubscriberFunction<T>): Promise<SubscriberId>; | ||
unsubscribe(topic: string, subscriberId: SubscriberId): Promise<void>; | ||
} | ||
|
||
export interface Publisher { | ||
broadcast<T>(topic: string, data: T): Promise<void>; | ||
broadcast<T extends { type: string }>(topic: string, data: T): Promise<void>; | ||
} | ||
|
||
export interface PubSub extends Subscriber, Publisher {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./liveViewManager"; | ||
export * from "./live_socket"; | ||
export * from "./liveSocket"; | ||
export * from "./wsMessageRouter"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.