订阅发布消息类型调整
This commit is contained in:
parent
0aa1bc102b
commit
461713baba
4
lib/app/JlGraphicApp.d.ts
vendored
4
lib/app/JlGraphicApp.d.ts
vendored
@ -358,7 +358,7 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
|
||||
/**
|
||||
* 发布websocket消息
|
||||
*/
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
}
|
||||
declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> implements IGraphicScene {
|
||||
private graphicStore;
|
||||
@ -496,7 +496,7 @@ declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> i
|
||||
/**
|
||||
* 发布websocket消息
|
||||
*/
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
/**
|
||||
* 处理图形状态
|
||||
* @param graphicStates
|
||||
|
4
lib/message/BasicMessageClient.d.ts
vendored
4
lib/message/BasicMessageClient.d.ts
vendored
@ -33,7 +33,7 @@ export declare abstract class MessageClient extends EventEmitter<MessageClientEv
|
||||
getOrNewSubClient(destination: string): SubscriptionClient;
|
||||
addSubscription(destination: string, handler: IMessageHandler): void;
|
||||
removeSubscription(destination: string, handle: IMessageHandler): void;
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
abstract get connected(): boolean;
|
||||
abstract close(): void;
|
||||
}
|
||||
@ -48,7 +48,7 @@ export declare class SubscriptionClient {
|
||||
removeHandler(handler: IMessageHandler): void;
|
||||
trySubscribe(): void;
|
||||
unsubscribe(): void;
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
handleMessage(data: any): void;
|
||||
onDisconnect(): void;
|
||||
}
|
||||
|
4
lib/message/MessageBroker.d.ts
vendored
4
lib/message/MessageBroker.d.ts
vendored
@ -69,7 +69,7 @@ export interface IMessageClient extends EventEmitter<MessageClientEvents> {
|
||||
* @param destination
|
||||
* @param message
|
||||
*/
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
/**
|
||||
* 是否已经连接
|
||||
*/
|
||||
@ -90,7 +90,7 @@ export declare class WsMsgCli {
|
||||
static registerSubscription(destination: string, handler: IMessageHandler): void;
|
||||
static unregisterSubscription(destination: string, handler: IMessageHandler): void;
|
||||
static registerAppMsgBroker(broker: AppWsMsgBroker): void;
|
||||
static publishMessage(destination: string, message: string): void;
|
||||
static publishMessage(destination: string, message: Uint8Array): void;
|
||||
static removeAppMsgBroker(broker: AppWsMsgBroker): void;
|
||||
static hasAppMsgBroker(): boolean;
|
||||
/**
|
||||
|
2
lib/message/MqttBroker.d.ts
vendored
2
lib/message/MqttBroker.d.ts
vendored
@ -10,5 +10,5 @@ export declare class MqttMsgClient extends MessageClient {
|
||||
unsubscribe0(destination: string): void;
|
||||
get connected(): boolean;
|
||||
close(): void;
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
}
|
||||
|
2
lib/message/WsMsgBroker.d.ts
vendored
2
lib/message/WsMsgBroker.d.ts
vendored
@ -7,6 +7,6 @@ export declare class StompMessagingClient extends MessageClient {
|
||||
get connected(): boolean;
|
||||
subscribe(destination: string, handle: HandleMessage): boolean;
|
||||
unsubscribe0(destination: string): void;
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
close(): void;
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
|
||||
/**
|
||||
* 发布websocket消息
|
||||
*/
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
}
|
||||
|
||||
abstract class GraphicSceneBase
|
||||
@ -1165,7 +1165,7 @@ abstract class GraphicSceneBase
|
||||
/**
|
||||
* 发布websocket消息
|
||||
*/
|
||||
publishMessage(destination: string, message: string) {
|
||||
publishMessage(destination: string, message: Uint8Array) {
|
||||
this.checkWsMsgCli();
|
||||
this.wsMsgBroker.publishMessage(destination, message);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ export abstract class MessageClient
|
||||
this.getOrNewSubClient(destination).removeHandler(handle);
|
||||
}
|
||||
|
||||
publishMessage(destination: string, message: string): void {
|
||||
publishMessage(destination: string, message: Uint8Array): void {
|
||||
const cli = this.getOrNewSubClient(destination);
|
||||
cli.publishMessage(destination, message);
|
||||
}
|
||||
@ -130,7 +130,7 @@ export class SubscriptionClient {
|
||||
this.mc.unsubscribe(this.destination);
|
||||
}
|
||||
|
||||
publishMessage(destination: string, message: string): void {
|
||||
publishMessage(destination: string, message: Uint8Array): void {
|
||||
if (this.mc.connected) {
|
||||
this.mc.publishMessage(destination, message);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export interface IMessageClient extends EventEmitter<MessageClientEvents> {
|
||||
* @param destination
|
||||
* @param message
|
||||
*/
|
||||
publishMessage(destination: string, message: string): void;
|
||||
publishMessage(destination: string, message: Uint8Array): void;
|
||||
/**
|
||||
* 是否已经连接
|
||||
*/
|
||||
@ -168,7 +168,7 @@ export class WsMsgCli {
|
||||
WsMsgCli.appMsgBroker.push(broker);
|
||||
}
|
||||
|
||||
static publishMessage(destination: string, message: string) {
|
||||
static publishMessage(destination: string, message: Uint8Array) {
|
||||
WsMsgCli.client.publishMessage(destination, message);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ export class AppWsMsgBroker {
|
||||
});
|
||||
}
|
||||
|
||||
publishMessage(destination: string, message: string) {
|
||||
publishMessage(destination: string, message: Uint8Array) {
|
||||
WsMsgCli.publishMessage(destination, message);
|
||||
}
|
||||
|
||||
|
@ -112,10 +112,10 @@ export class MqttMsgClient extends MessageClient {
|
||||
console.warn('MQTT 消息客户端关闭失败', error);
|
||||
}
|
||||
}
|
||||
publishMessage(destination: string, message: string): void {
|
||||
publishMessage(destination: string, message: Uint8Array): void {
|
||||
console.debug('MQTT发布消息');
|
||||
if(this.connected) {
|
||||
this.cli.publish(destination, message);
|
||||
this.cli.publish(destination, message as Buffer);
|
||||
}else {
|
||||
console.warn('MQTT 未连接,消息发布失败');
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export class StompMessagingClient extends MessageClient {
|
||||
this.cli.unsubscribe(destination);
|
||||
}
|
||||
|
||||
publishMessage(destination: string, message: string): void {
|
||||
publishMessage(destination: string, message: Uint8Array): void {
|
||||
console.debug('MQTT发布消息:未实现');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user