You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.4 KiB
64 lines
2.4 KiB
import {BaseAction} from "./BaseAction";
|
|
import {AppAction} from "./AppAction";
|
|
import {CellColorAction, isCellColorAction} from "./CellAction";
|
|
import {isUserActiveColorAction, UserActiveColorAction} from "./UserAction";
|
|
|
|
export const CLIENT_HELLO = "CLIENT_HELLO"
|
|
/** Sent when the client connects. */
|
|
export interface ClientHelloCommand extends BaseAction {
|
|
readonly type: typeof CLIENT_HELLO
|
|
/** The protocol version the client is running on */
|
|
readonly version: number
|
|
}
|
|
export function isClientHelloCommand(action: AppAction): action is ClientHelloCommand {
|
|
return action.type === CLIENT_HELLO
|
|
}
|
|
|
|
export const CLIENT_REFRESH = "CLIENT_REFRESH"
|
|
/** Sent when the user requests a refresh. */
|
|
export interface ClientRefreshCommand extends BaseAction {
|
|
readonly type: typeof CLIENT_REFRESH
|
|
}
|
|
export function isClientRefreshCommand(action: AppAction): action is ClientRefreshCommand {
|
|
return action.type === CLIENT_REFRESH
|
|
}
|
|
|
|
export const CLIENT_PENDING = "CLIENT_PENDING"
|
|
/** Synthesized when a user action is ready to be sent to the server. */
|
|
export interface ClientPendingAction extends BaseAction {
|
|
readonly type: typeof CLIENT_PENDING
|
|
readonly pending: SendableAction
|
|
}
|
|
export function isClientPendingAction(action: AppAction): action is ClientPendingAction {
|
|
return action.type === CLIENT_PENDING
|
|
}
|
|
|
|
export interface SentAction {
|
|
readonly id: number
|
|
readonly action: SendableAction
|
|
}
|
|
|
|
export const CLIENT_ACT = "CLIENT_ACT"
|
|
/** Sent to the server when the user performs an action. */
|
|
export interface ClientActCommand extends BaseAction {
|
|
readonly type: typeof CLIENT_ACT
|
|
readonly actions: readonly SentAction[]
|
|
}
|
|
export function isClientActCommand(action: AppAction): action is ClientActCommand {
|
|
return action.type === CLIENT_ACT
|
|
}
|
|
|
|
export type SendableAction = CellColorAction | UserActiveColorAction
|
|
export function isSendableAction(action: AppAction): action is SendableAction {
|
|
return isCellColorAction(action) || isUserActiveColorAction(action)
|
|
}
|
|
|
|
export type ClientCommand = ClientHelloCommand | ClientRefreshCommand | ClientActCommand
|
|
export function isClientCommand(action: AppAction): action is ClientCommand {
|
|
return isClientHelloCommand(action) || isClientRefreshCommand(action) || isClientActCommand(action)
|
|
}
|
|
|
|
export type ClientAction = ClientCommand | ClientPendingAction
|
|
export function isClientAction(action: AppAction): action is ClientAction {
|
|
return isClientCommand(action) || isClientPendingAction(action)
|
|
} |