socketStore.d.ts 1.69 KB

export enum SocketStoreEnum {
  CONNECTION_POOL = 'connectionPool',
  SUBSCRIBE_POOL = 'subscribePool',
  CACHE_MESSAGE = 'cacheMessage',
  CURRENT_SUBSCRIBE_ID = 'currentSubscribeId',
  UNSUBSCRIBE_POOL = 'unsubscribePool',
  COMPONENT_UPDATE_FN_POOL = 'componentUpdateFnPool'
}

export interface KeyBoundComponentList {
  componentId: string
}

export interface SocketSendMessageItemType {
  cmdId: number
  entityId: string
  entityType: string
  keys: string
  scope: string
  unsubscribe?: boolean
}

export interface SocketSendMessageType {
  tsSubCmds: SocketSendMessageItemType[]
}

export interface SocketReceiveMessageType {
  subscriptionId: number,
  errorCode: number,
  errorMsg: Nullable<string>,
  data: {
    [key: string]: [number, string]
  },
  latestValues: {
    [key: string]: number
  }
}

export interface SocketConnectionPoolType {
  [key: string]: {
    [key: string]: KeyBoundComponentList[]
  }
}

export interface CacheMessageType {
  [key: number]: SocketReceiveMessageType[]
}

export interface SubscribePoolType {
  subscribeId: number
  entityId: string
}

export interface SocketComponentRecord {
  componentId: string
  keys: string[]
}

export interface UnsubscribePoolType {
  subscribeId: number,
  message: SocketSendMessageType 
}

export interface ComponentUpdateFnPoolType {
  [key: string]: Fn
}

export interface SocketStoreType {
  [SocketStoreEnum.CONNECTION_POOL]: SocketConnectionPoolType,
  [SocketStoreEnum.SUBSCRIBE_POOL]: SubscribePoolType[],
  [SocketStoreEnum.CACHE_MESSAGE]: CacheMessageType,
  [SocketStoreEnum.CURRENT_SUBSCRIBE_ID]: number,
  [SocketStoreEnum.UNSUBSCRIBE_POOL]: UnsubscribePoolType[]
  [SocketStoreEnum.COMPONENT_UPDATE_FN_POOL]: ComponentUpdateFnPoolType
}