import { SignalSourceEntity } from "./SignalSourceEntity"; import ApplicationConfigEntity from "./ApplicationConfigEntity"; import { WindowOpenNotifyEntity } from "./MultimediaWindowEntity"; export namespace Protocol { export class Commands { public static get PROTOCOL_PREFIX() { return "_"; } public static get kUnKnowCommand() { return Commands.PROTOCOL_PREFIX + "UnKnowCommand"; } public static get kSearchDevice() { return Commands.PROTOCOL_PREFIX + "SearchDevice"; } public static get kEditNetworkInterfaceInfo() { return Commands.PROTOCOL_PREFIX + "EditNetworkInterfaceInfo"; } public static get kExecCommand() { return Commands.PROTOCOL_PREFIX + "ExecCommand"; } public static get kRestoreDevice() { return Commands.PROTOCOL_PREFIX + "RestoreDevice"; } public static get kLogin() { return Commands.PROTOCOL_PREFIX + "Login"; } public static get kLogout() { return Commands.PROTOCOL_PREFIX + "Logout"; } public static get kRpcGetWindows() { return Commands.PROTOCOL_PREFIX + "RpcGetWindows"; } public static get kRpcGetSignalSources() { return Commands.PROTOCOL_PREFIX + "RpcGetSignalSources"; } public static get kRpcGetApplicationConfig() { return Commands.PROTOCOL_PREFIX + "RpcGetApplicationConfig"; } public static get kMoveWindow() { return Commands.PROTOCOL_PREFIX + "MoveWindow"; } public static get kResizeWindow() { return Commands.PROTOCOL_PREFIX + "ResizeWindow"; } public static get kOpenWindow() { return Commands.PROTOCOL_PREFIX + "OpenWindow"; } public static get kCloseWindow() { return Commands.PROTOCOL_PREFIX + "CloseWindow"; } public static get kWindowOtherStateChanged() { return Commands.PROTOCOL_PREFIX + "WindowOtherStateChanged"; } public static get kFocuseWindow() { return Commands.PROTOCOL_PREFIX + "FocuseWindow"; } public static get kRpcAddSignalSourceGroup() { return Commands.PROTOCOL_PREFIX + "RpcAddSignalSourceGroup"; } public static get kRpcDeleteSignalSourceGroup() { return Commands.PROTOCOL_PREFIX + "RpcDeleteSignalSourceGroup"; } public static get kRpcEditSignalSourceGroup() { return Commands.PROTOCOL_PREFIX + "RpcEditSignalSourceGroup"; } public static get kRpcAddSignalSource() { return Commands.PROTOCOL_PREFIX + "RpcAddSignalSource"; } public static get kRpcDeleteSignalSource() { return Commands.PROTOCOL_PREFIX + "RpcDeleteSignalSource"; } public static get kRpcEditSignalSource() { return Commands.PROTOCOL_PREFIX + "RpcEditSignalSource"; } public static get kSetApplicationConfig() { return Commands.PROTOCOL_PREFIX + "SetApplicationConfig"; } public static get kRestartDeviceCommand() { return Commands.PROTOCOL_PREFIX + "RestartDeviceCommand"; } static _all_commands = new Set([ Commands.kUnKnowCommand, Commands.kSearchDevice, Commands.kEditNetworkInterfaceInfo, Commands.kExecCommand, Commands.kRestoreDevice, Commands.kLogin, Commands.kLogout, Commands.kRpcGetWindows, Commands.kRpcGetSignalSources, Commands.kRpcGetApplicationConfig, Commands.kMoveWindow, Commands.kResizeWindow, Commands.kOpenWindow, Commands.kCloseWindow, Commands.kWindowOtherStateChanged, Commands.kRpcAddSignalSourceGroup, Commands.kRpcDeleteSignalSourceGroup, Commands.kRpcEditSignalSourceGroup, Commands.kRpcAddSignalSource, Commands.kRpcDeleteSignalSource, Commands.kRpcEditSignalSource, Commands.kSetApplicationConfig, ]); public static get AllCommands() { return this._all_commands; } } export class PacketEntity { public static get FLAG_REQUEST() { return 0; } public static get FLAG_RESPONSE() { return 1; } public static get FLAG_NOTIFY() { return 2; } /** 是否出现异常,如果是异常,则为 ExceptionEntity */ has_exception = false; /** 0: 请求 1: 响应 */ flag = PacketEntity.FLAG_REQUEST; /** rpc 消息 ID,默认 0 */ rpc_id = 0; /** 命令 */ command = Protocol.Commands.kUnKnowCommand; } export class LoginRequest extends PacketEntity { user_name = ""; password = ""; constructor(user_name?: string, password?: string) { super(); this.user_name = user_name ?? ""; this.password = password ?? ""; this.command = Commands.kLogin; } } export class LoginResponse extends PacketEntity { success = false; error_code = 0; constructor() { super(); this.command = Commands.kLogin; } } export class GetSignalSourcesRequest extends PacketEntity { timestamp = new Date().getMilliseconds(); constructor(rpcid?: number) { super(); this.rpc_id = rpcid ?? 0; this.command = Commands.kRpcGetSignalSources; } } export class GetSignalSourcesResponse extends PacketEntity { signal_sources: SignalSourceEntity[] = []; signal_source_groups: [] = []; constructor() { super(); this.command = Commands.kRpcGetSignalSources; } } export class GetApplicationConfigRequestEntity extends PacketEntity { timestamp: number = new Date().getMilliseconds(); constructor(rpcid?: number) { super(); this.rpc_id = rpcid ?? 0; this.command = Commands.kRpcGetApplicationConfig; } } export class GetApplicationConfigResponseEntity extends PacketEntity { config: ApplicationConfigEntity | null = null; constructor() { super(); this.command = Commands.kRpcGetApplicationConfig; } } export class GetWindowsRequestEntity extends PacketEntity { timestamp: number = new Date().getMilliseconds(); constructor(rpcid?: number) { super(); this.rpc_id = rpcid ?? 0; this.command = Commands.kRpcGetWindows; } } export class GetWindowsResponseEntity extends PacketEntity { windows: WindowOpenNotifyEntity[] = []; constructor() { super(); this.command = Commands.kRpcGetWindows; } } export class MoveWindowRequestEntity extends PacketEntity { window_id: number = 0; x: number = 0; y: number = 0; constructor(window_id: number, x: number, y: number) { super(); this.command = Commands.kMoveWindow; this.window_id = window_id ?? 0; this.x = x ?? 0; this.y = y ?? 0; } } export class ResizeWindowRequestEntity extends PacketEntity { window_id: number = 0; width: number = 0; height: number = 0; constructor(window_id: number, width: number, height: number) { super(); this.command = Commands.kResizeWindow; this.window_id = window_id ?? 0; this.width = width ?? 0; this.height = height ?? 0; } } export class CloseWindowRequestEntity extends PacketEntity { window_id: number = 0; constructor(window_id: number) { super(); this.command = Commands.kCloseWindow; this.window_id = window_id ?? 0; } } export class OpenWindowRequestEntity extends PacketEntity { signal_source: string = ""; x: number = 0; y: number = 0; width: number = 0; height: number = 0; constructor( signal_source: string, x: number, y: number, width: number, height: number ) { super(); this.command = Commands.kOpenWindow; this.signal_source = signal_source ?? ""; this.x = x ?? 0; this.y = y ?? 0; this.width = width ?? 0; this.height = height ?? 0; } } export class WindowCloseNotifyEntity extends PacketEntity { window_id: number = 0; constructor() { super(); this.command = Commands.kCloseWindow; } } export class WindowOpenNotifyEntity extends PacketEntity { window_id: number = 0; signal_source: string = ""; x: number = 0; y: number = 0; width: number = 0; height: number = 0; constructor() { super(); this.command = Commands.kOpenWindow; } } export class WindowMoveNotifyEntity extends PacketEntity { window_id: number = 0; x: number = 0; y: number = 0; constructor() { super(); this.command = Commands.kMoveWindow; } } export class WindowResizeNotifyEntity extends PacketEntity { window_id: number = 0; width: number = 0; height: number = 0; constructor() { super(); this.command = Commands.kResizeWindow; } } export class AddSignalSourcesGroupRequestEntity extends Protocol.PacketEntity { parent_uuid = ""; name = ""; constructor(rcp_id?: number, parent_uuid?: string, name?: string) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcAddSignalSourceGroup; this.parent_uuid = parent_uuid ?? ""; this.name = name ?? ""; } } export class AddSignalSourcesGroupResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcAddSignalSourceGroup; } } export class EditSignalSourcesGroupRequestEntity extends Protocol.PacketEntity { uuid = ""; name = ""; constructor(rcp_id?: number, uuid?: string, name?: string) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcEditSignalSourceGroup; this.uuid = uuid ?? ""; this.name = name ?? ""; } } export class EditSignalSourcesGroupResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcEditSignalSourceGroup; } } export class DeleteSignalSourcesGroupRequestEntity extends Protocol.PacketEntity { uuid = ""; constructor(rcp_id?: number, uuid?: string) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcDeleteSignalSourceGroup; this.uuid = uuid ?? ""; } } export class DeleteSignalSourcesGroupResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcDeleteSignalSource; } } export class AddSignalSourcesRequestEntity extends Protocol.PacketEntity { entity: SignalSourceEntity | null = null; constructor(rcp_id?: number, entity?: SignalSourceEntity) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcAddSignalSource; this.entity = entity ?? new SignalSourceEntity(); } } export class AddSignalSourcesResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcAddSignalSourceGroup; } } export class EditSignalSourcesRequestEntity extends Protocol.PacketEntity { entity: SignalSourceEntity | null = null; parent_uuid: string = ""; constructor( rcp_id?: number, entity?: SignalSourceEntity, parent_uuid?: string ) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcEditSignalSource; this.entity = entity ?? new SignalSourceEntity(); this.parent_uuid = parent_uuid ?? ""; } } export class EditSignalSourcesResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcEditSignalSource; } } export class DeleteSignalSourcesRequestEntity extends Protocol.PacketEntity { uuid: string = ""; constructor(rcp_id?: number, uuid?: string) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kRpcDeleteSignalSource; this.uuid = uuid ?? ""; } } export class DeleteSignalSourcesResponseEntity extends Protocol.PacketEntity { success = false; constructor() { super(); this.command = Protocol.Commands.kRpcDeleteSignalSource; } } export class SignalSourceGroupEntity extends Protocol.PacketEntity { parent_uuid: string = ""; name: string = ""; system_default: boolean = false; } export class SignalSourceAddNotifyEntity extends Protocol.PacketEntity { signal_source: SignalSourceEntity = new SignalSourceEntity(); } export class SignalSourceDeleteNotifyEntity extends Protocol.PacketEntity { uuid: string = ""; } export class SignalSourceEditNotifyEntity extends Protocol.PacketEntity { signal_source: SignalSourceEntity = new SignalSourceEntity(); } export class SignalSourceGroupAddNotifyEntity extends Protocol.PacketEntity { signal_source_group: SignalSourceGroupEntity = new SignalSourceGroupEntity(); } export class SignalSourceGroupDeleteNotifyEntity extends Protocol.PacketEntity { uuid: string = ""; } export class SignalSourceGroupEditNotifyEntity extends Protocol.PacketEntity { signal_source_group: SignalSourceGroupEntity = new SignalSourceGroupEntity(); } export class SetApplicationConfigRequestEntity extends Protocol.PacketEntity { key: string = ""; value: string = ""; constructor(rcp_id?: number, key?: string, value?: string) { super(); this.rpc_id = rcp_id ?? 0; this.command = Protocol.Commands.kSetApplicationConfig; this.value = value ?? ""; this.key = key ?? ""; } } export class ApplicationConfigChangeNotifyEntity extends Protocol.PacketEntity { key: string = ""; value: string = ""; } export class RestartDeviceRequestEntity extends Protocol.PacketEntity { timestamp: number; constructor() { super(); this.timestamp = new Date().getUTCMilliseconds(); this.command = Protocol.Commands.kRestartDeviceCommand; this.flag = Protocol.PacketEntity.FLAG_REQUEST; this.rpc_id = 0; } } }