add rpc system to improve ipc

This commit is contained in:
Thomas Nordquist
2022-02-27 18:44:17 +01:00
parent 205ea00c41
commit e1493db7c8
27 changed files with 252 additions and 303 deletions

View File

@@ -1,39 +1,22 @@
import { Event } from './'
import { RpcEvent } from './EventSystem/Rpc'
interface StorageEvent {
transactionId: string
export interface StoreCommand {
store: string
data: any
}
export interface StoreCommand extends StorageEvent {
store?: string
data?: any
error?: any
}
export interface LoadCommand extends StorageEvent {
export interface LoadCommand {
store: string
}
export const storageStoreEvent: Event<StoreCommand> = {
export const storageStoreEvent: RpcEvent<StoreCommand, void> = {
topic: 'storage/store',
}
export const storageLoadEvent: Event<LoadCommand> = {
export const storageLoadEvent: RpcEvent<LoadCommand, StoreCommand> = {
topic: 'storage/load',
}
export function makeStorageAcknowledgementEvent(transactionId: string): Event<StoreCommand> {
return {
topic: `storage/ack/${transactionId}`,
}
}
export function makeStorageResponseEvent(transactionId: string): Event<StoreCommand> {
return {
topic: `storage/response/${transactionId}`,
}
}
export const storageClearEvent: Event<StorageEvent> = {
export const storageClearEvent: RpcEvent<void, void> = {
topic: 'storage/clear',
}