代码同步
This commit is contained in:
parent
7aa731d9f8
commit
9a706820f9
@ -1 +1 @@
|
||||
Subproject commit 6626ad51140f611fa8583895c27c6a788fca1d7f
|
||||
Subproject commit 7e4eaed0cf06d68c75cb51c30329eff5fe4d1e3f
|
@ -119,6 +119,7 @@ export async function loadLineNetDatas(app: GraphicApp) {
|
||||
destination: '/queue/lineNet',
|
||||
messageConverter: (message: Uint8Array) => {
|
||||
const storage = state.WsLineNetMessage.deserialize(message);
|
||||
console.log(storage, 'storage');
|
||||
storage.offset.forEach((item) => {
|
||||
states.push(new TrainLineState(item));
|
||||
});
|
||||
|
@ -152,12 +152,32 @@ export class StompCli {
|
||||
}
|
||||
|
||||
// 状态订阅消息转换器
|
||||
export type MessageConverter = (message: Uint8Array) => GraphicState[];
|
||||
export type GraphicStateMessageConvert = (
|
||||
message: Uint8Array
|
||||
) => GraphicState[];
|
||||
|
||||
// 订阅消息处理器
|
||||
export type SubscriptionMessageHandle = (message: Uint8Array) => void;
|
||||
|
||||
// 图形app状态订阅
|
||||
export interface AppStateSubscription {
|
||||
/**
|
||||
* 订阅路径
|
||||
*/
|
||||
destination: string;
|
||||
messageConverter: MessageConverter;
|
||||
subscription?: StompSubscription; // 订阅成功对象,用于取消订阅
|
||||
/**
|
||||
* 图形状态消息转换
|
||||
*/
|
||||
messageConverter?: GraphicStateMessageConvert;
|
||||
/**
|
||||
* 订阅消息处理
|
||||
*/
|
||||
messageHandle?: SubscriptionMessageHandle;
|
||||
/**
|
||||
* 订阅成功对象,用于取消订阅
|
||||
* 非客户端使用
|
||||
*/
|
||||
subscription?: StompSubscription;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,8 +200,16 @@ export class AppWsMsgBroker {
|
||||
sub.subscription = StompCli.trySubscribe(
|
||||
sub.destination,
|
||||
(message: Message) => {
|
||||
const graphicStates = sub.messageConverter(message.binaryBody);
|
||||
this.app.handleGraphicStates(graphicStates);
|
||||
if (sub.messageConverter) {
|
||||
const graphicStates = sub.messageConverter(message.binaryBody);
|
||||
this.app.handleGraphicStates(graphicStates);
|
||||
} else if (sub.messageHandle) {
|
||||
sub.messageHandle(message.binaryBody);
|
||||
} else {
|
||||
console.error(
|
||||
`订阅destination:${sub.destination}没有消息处理器或图形状态消息转换器`
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
// console.log('代理订阅结果', sub.subscription)
|
||||
|
Loading…
Reference in New Issue
Block a user