Compare commits

...

2 Commits

Author SHA1 Message Date
joylink_fanyuhong
af71702840 打包 2024-10-08 15:01:19 +08:00
joylink_fanyuhong
461713baba 订阅发布消息类型调整 2024-10-08 14:58:19 +08:00
10 changed files with 19 additions and 19 deletions

View File

@ -358,7 +358,7 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
/** /**
* websocket消息 * websocket消息
*/ */
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
} }
declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> implements IGraphicScene { declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> implements IGraphicScene {
private graphicStore; private graphicStore;
@ -496,7 +496,7 @@ declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> i
/** /**
* websocket消息 * websocket消息
*/ */
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
/** /**
* *
* @param graphicStates * @param graphicStates

View File

@ -33,7 +33,7 @@ export declare abstract class MessageClient extends EventEmitter<MessageClientEv
getOrNewSubClient(destination: string): SubscriptionClient; getOrNewSubClient(destination: string): SubscriptionClient;
addSubscription(destination: string, handler: IMessageHandler): void; addSubscription(destination: string, handler: IMessageHandler): void;
removeSubscription(destination: string, handle: 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 get connected(): boolean;
abstract close(): void; abstract close(): void;
} }
@ -48,7 +48,7 @@ export declare class SubscriptionClient {
removeHandler(handler: IMessageHandler): void; removeHandler(handler: IMessageHandler): void;
trySubscribe(): void; trySubscribe(): void;
unsubscribe(): void; unsubscribe(): void;
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
handleMessage(data: any): void; handleMessage(data: any): void;
onDisconnect(): void; onDisconnect(): void;
} }

View File

@ -69,7 +69,7 @@ export interface IMessageClient extends EventEmitter<MessageClientEvents> {
* @param destination * @param destination
* @param message * @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 registerSubscription(destination: string, handler: IMessageHandler): void;
static unregisterSubscription(destination: string, handler: IMessageHandler): void; static unregisterSubscription(destination: string, handler: IMessageHandler): void;
static registerAppMsgBroker(broker: AppWsMsgBroker): 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 removeAppMsgBroker(broker: AppWsMsgBroker): void;
static hasAppMsgBroker(): boolean; static hasAppMsgBroker(): boolean;
/** /**
@ -145,7 +145,7 @@ export declare class AppWsMsgBroker {
unsbuscribe(destination: string): void; unsbuscribe(destination: string): void;
unsubscribeAll(): void; unsubscribeAll(): void;
resubscribeAll(): void; resubscribeAll(): void;
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
/** /**
* Stomp客户端移除此消息代理 * Stomp客户端移除此消息代理
*/ */

View File

@ -10,5 +10,5 @@ export declare class MqttMsgClient extends MessageClient {
unsubscribe0(destination: string): void; unsubscribe0(destination: string): void;
get connected(): boolean; get connected(): boolean;
close(): void; close(): void;
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
} }

View File

@ -7,6 +7,6 @@ export declare class StompMessagingClient extends MessageClient {
get connected(): boolean; get connected(): boolean;
subscribe(destination: string, handle: HandleMessage): boolean; subscribe(destination: string, handle: HandleMessage): boolean;
unsubscribe0(destination: string): void; unsubscribe0(destination: string): void;
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
close(): void; close(): void;
} }

View File

@ -615,7 +615,7 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
/** /**
* websocket消息 * websocket消息
*/ */
publishMessage(destination: string, message: string): void; publishMessage(destination: string, message: Uint8Array): void;
} }
abstract class GraphicSceneBase abstract class GraphicSceneBase
@ -1165,7 +1165,7 @@ abstract class GraphicSceneBase
/** /**
* websocket消息 * websocket消息
*/ */
publishMessage(destination: string, message: string) { publishMessage(destination: string, message: Uint8Array) {
this.checkWsMsgCli(); this.checkWsMsgCli();
this.wsMsgBroker.publishMessage(destination, message); this.wsMsgBroker.publishMessage(destination, message);
} }

View File

@ -70,7 +70,7 @@ export abstract class MessageClient
this.getOrNewSubClient(destination).removeHandler(handle); this.getOrNewSubClient(destination).removeHandler(handle);
} }
publishMessage(destination: string, message: string): void { publishMessage(destination: string, message: Uint8Array): void {
const cli = this.getOrNewSubClient(destination); const cli = this.getOrNewSubClient(destination);
cli.publishMessage(destination, message); cli.publishMessage(destination, message);
} }
@ -130,7 +130,7 @@ export class SubscriptionClient {
this.mc.unsubscribe(this.destination); this.mc.unsubscribe(this.destination);
} }
publishMessage(destination: string, message: string): void { publishMessage(destination: string, message: Uint8Array): void {
if (this.mc.connected) { if (this.mc.connected) {
this.mc.publishMessage(destination, message); this.mc.publishMessage(destination, message);
} }

View File

@ -88,7 +88,7 @@ export interface IMessageClient extends EventEmitter<MessageClientEvents> {
* @param destination * @param destination
* @param message * @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); WsMsgCli.appMsgBroker.push(broker);
} }
static publishMessage(destination: string, message: string) { static publishMessage(destination: string, message: Uint8Array) {
WsMsgCli.client.publishMessage(destination, message); 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); WsMsgCli.publishMessage(destination, message);
} }

View File

@ -112,10 +112,10 @@ export class MqttMsgClient extends MessageClient {
console.warn('MQTT 消息客户端关闭失败', error); console.warn('MQTT 消息客户端关闭失败', error);
} }
} }
publishMessage(destination: string, message: string): void { publishMessage(destination: string, message: Uint8Array): void {
console.debug('MQTT发布消息'); console.debug('MQTT发布消息');
if(this.connected) { if(this.connected) {
this.cli.publish(destination, message); this.cli.publish(destination, message as Buffer);
}else { }else {
console.warn('MQTT 未连接,消息发布失败'); console.warn('MQTT 未连接,消息发布失败');
} }

View File

@ -77,7 +77,7 @@ export class StompMessagingClient extends MessageClient {
this.cli.unsubscribe(destination); this.cli.unsubscribe(destination);
} }
publishMessage(destination: string, message: string): void { publishMessage(destination: string, message: Uint8Array): void {
console.debug('MQTT发布消息:未实现'); console.debug('MQTT发布消息:未实现');
} }