更新版本

This commit is contained in:
joylink_fanyuhong 2024-09-28 10:13:07 +08:00
parent 2255232499
commit 02ac6e6deb
10 changed files with 3844 additions and 377 deletions

View File

@ -355,6 +355,10 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
* websocket订阅
*/
unsubscribe(destination: string): void;
/**
* websocket消息
*/
publishMessage(destination: string, message: string): void;
}
declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> implements IGraphicScene {
private graphicStore;
@ -489,6 +493,10 @@ declare abstract class GraphicSceneBase extends EventEmitter<GraphicAppEvents> i
* websocket订阅
*/
unsubscribe(destination: string): void;
/**
* websocket消息
*/
publishMessage(destination: string, message: string): void;
/**
*
* @param graphicStates

2
lib/index.d.ts vendored
View File

@ -1,4 +1,4 @@
/// <reference path="../global.d.ts" />
/// <reference types="global" />
export * as GraphicsExtras from '@pixi/graphics-extras';
export * from './app';
export * from './core';

View File

@ -5279,6 +5279,10 @@ class MessageClient extends EventEmitter {
removeSubscription(destination, handle) {
this.getOrNewSubClient(destination).removeHandler(handle);
}
publishMessage(destination, message) {
const cli = this.getOrNewSubClient(destination);
cli.publishMessage(destination, message);
}
}
class SubscriptionClient {
mc;
@ -5321,6 +5325,11 @@ class SubscriptionClient {
unsubscribe() {
this.mc.unsubscribe(this.destination);
}
publishMessage(destination, message) {
if (this.mc.connected) {
this.mc.publishMessage(destination, message);
}
}
handleMessage(data) {
if (this.protocol === 'json') {
console.debug('收到消息:', data);
@ -5403,6 +5412,9 @@ class StompMessagingClient extends MessageClient {
unsubscribe0(destination) {
this.cli.unsubscribe(destination);
}
publishMessage(destination, message) {
console.debug('MQTT发布消息:未实现');
}
close() {
this.cli.deactivate();
}
@ -5522,6 +5534,15 @@ class MqttMsgClient extends MessageClient {
console.warn('MQTT 消息客户端关闭失败', error);
}
}
publishMessage(destination, message) {
console.debug('MQTT发布消息');
if (this.connected) {
this.cli.publish(destination, message);
}
else {
console.warn('MQTT 未连接,消息发布失败');
}
}
}
var ClientEngine;
@ -5601,6 +5622,9 @@ class WsMsgCli {
static registerAppMsgBroker(broker) {
WsMsgCli.appMsgBroker.push(broker);
}
static publishMessage(destination, message) {
WsMsgCli.client.publishMessage(destination, message);
}
static removeAppMsgBroker(broker) {
const index = WsMsgCli.appMsgBroker.findIndex((mb) => mb == broker);
if (index >= 0) {
@ -5674,6 +5698,9 @@ class AppWsMsgBroker {
WsMsgCli.registerSubscription(destination, handler);
});
}
publishMessage(destination, message) {
WsMsgCli.publishMessage(destination, message);
}
/**
* 取消所有订阅从通用Stomp客户端移除此消息代理
*/
@ -7130,6 +7157,13 @@ class GraphicSceneBase extends EventEmitter {
this.checkWsMsgCli();
this.wsMsgBroker.unsbuscribe(destination);
}
/**
* 发布websocket消息
*/
publishMessage(destination, message) {
this.checkWsMsgCli();
this.wsMsgBroker.publishMessage(destination, message);
}
/**
* 处理图形状态
* @param graphicStates

View File

@ -33,6 +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;
abstract get connected(): boolean;
abstract close(): void;
}
@ -47,6 +48,7 @@ export declare class SubscriptionClient {
removeHandler(handler: IMessageHandler): void;
trySubscribe(): void;
unsubscribe(): void;
publishMessage(destination: string, message: string): void;
handleMessage(data: any): void;
onDisconnect(): void;
}

View File

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

View File

@ -8,7 +8,7 @@ export declare class MqttMsgClient extends MessageClient {
constructor(options: CompleteMessageCliOption);
subscribe(destination: string, handle: HandleMessage): boolean;
unsubscribe0(destination: string): void;
publishMessage(destination: string, message: string): void;
get connected(): boolean;
close(): void;
publishMessage(destination: string, message: string): void;
}

View File

@ -7,5 +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;
close(): void;
}

3482
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "graphic-pixi",
"version": "0.1.14",
"version": "0.1.15",
"description": "基于pixijs的图形应用、绘制应用框架",
"productName": "Graphic-pixi",
"author": "walker <shengxuqiang@joylink.club>",

680
yarn.lock

File diff suppressed because it is too large Load Diff