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.
49 lines
710 B
49 lines
710 B
2 years ago
|
/**
|
||
|
* 会话消息类型枚举
|
||
|
*/
|
||
2 years ago
|
export const WorkerMessageType = {
|
||
|
REQUEST: 'REQUEST',
|
||
|
REPLY: 'REPLY',
|
||
|
};
|
||
2 years ago
|
|
||
|
/**
|
||
|
* 会话消息
|
||
|
*/
|
||
|
export interface IWorkerMessage {
|
||
2 years ago
|
messageType: string;
|
||
2 years ago
|
actionType: string;
|
||
|
sessionId: string;
|
||
|
|
||
|
/**
|
||
|
* 数据交换参数
|
||
|
*/
|
||
|
payload: any;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 通信控制器需要实现的 interface
|
||
|
*/
|
||
|
export interface IWorkerController {
|
||
|
|
||
|
/**
|
||
|
* 事务处理器
|
||
|
*/
|
||
|
actionHandler: (message: IWorkerMessage) => Promise<any>;
|
||
|
}
|
||
2 years ago
|
|
||
|
/**
|
||
|
* Worker创建配置
|
||
|
*/
|
||
|
export interface IWorkerOptions {
|
||
|
|
||
|
/**
|
||
|
* worker 资源 url
|
||
|
*/
|
||
|
workerUrl: string;
|
||
|
|
||
|
/**
|
||
|
* worker 实例名称
|
||
|
*/
|
||
|
workerName: string;
|
||
|
}
|