From 94446e40fcdb5d84de1132f8359dc9b5dd0769d0 Mon Sep 17 00:00:00 2001 From: noear Date: Fri, 1 Mar 2024 12:56:47 +0800 Subject: [PATCH] 1.2.4 --- LOG.md | 3 ++ folkmq-lang-java/folkmq-broker/pom.xml | 2 +- .../java/org/noear/folkmq/broker/App.java | 12 +++++ folkmq-lang-java/folkmq-parent/pom.xml | 6 +-- folkmq-lang-java/folkmq-pro/pom.xml | 2 +- folkmq-lang-java/folkmq-server/pom.xml | 2 +- .../java/org/noear/folkmq/server/pro/App.java | 12 +++++ folkmq-lang-java/folkmq-solon/pom.xml | 2 +- folkmq-lang-java/folkmq-test/pom.xml | 2 +- .../folkmq-transport-java-tcp/pom.xml | 2 +- .../folkmq-transport-java-websocket/pom.xml | 2 +- .../folkmq-transport-netty/pom.xml | 2 +- .../folkmq-transport-smartsocket/pom.xml | 2 +- folkmq-lang-java/folkmq/pom.xml | 2 +- .../main/java/org/noear/folkmq/FolkMQ.java | 2 +- .../folkmq-test/demo02-node-ws/package.json | 4 +- folkmq-lang-js/folkmq/package.json | 2 +- folkmq-lang-js/folkmq/src/FolkMQ.ts | 2 +- folkmq-lang-js/folkmq/webpack.md | 47 +++++++++++++++++++ folkmq-lang-js/release/folkmq.js | 6 +++ 20 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 folkmq-lang-js/folkmq/webpack.md create mode 100644 folkmq-lang-js/release/folkmq.js diff --git a/LOG.md b/LOG.md index 6c4ccf65..559aa729 100644 --- a/LOG.md +++ b/LOG.md @@ -1,3 +1,6 @@ +### 1.2.4 +* 添加 folkmq-server 对 ws 输传协议的支持 + ### 1.2.3 * 添加 rpc 异常传导机制 * 完成 javascript 语言客户端实现 diff --git a/folkmq-lang-java/folkmq-broker/pom.xml b/folkmq-lang-java/folkmq-broker/pom.xml index f0955ed1..f65d2f3e 100644 --- a/folkmq-lang-java/folkmq-broker/pom.xml +++ b/folkmq-lang-java/folkmq-broker/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-broker/src/main/java/org/noear/folkmq/broker/App.java b/folkmq-lang-java/folkmq-broker/src/main/java/org/noear/folkmq/broker/App.java index f04ffcc4..1962dcb6 100644 --- a/folkmq-lang-java/folkmq-broker/src/main/java/org/noear/folkmq/broker/App.java +++ b/folkmq-lang-java/folkmq-broker/src/main/java/org/noear/folkmq/broker/App.java @@ -1,5 +1,9 @@ package org.noear.folkmq.broker; +import org.noear.socketd.SocketD; +import org.noear.socketd.transport.java_websocket.WsNioProvider; +import org.noear.socketd.transport.netty.tcp.TcpNioProvider; +import org.noear.socketd.transport.netty.udp.UdpNioProvider; import org.noear.solon.Solon; import org.noear.solon.validation.ValidatorException; @@ -10,6 +14,14 @@ public class App { public static void main(String[] args) { Solon.start(App.class, args, app -> { + //手动注册(避免 spi 失效) + SocketD.registerServerProvider(new WsNioProvider()); + SocketD.registerClientProvider(new WsNioProvider()); + SocketD.registerServerProvider(new TcpNioProvider()); + SocketD.registerClientProvider(new TcpNioProvider()); + SocketD.registerServerProvider(new UdpNioProvider()); + SocketD.registerClientProvider(new UdpNioProvider()); + //启用安全停止 app.cfg().stopSafe(true); diff --git a/folkmq-lang-java/folkmq-parent/pom.xml b/folkmq-lang-java/folkmq-parent/pom.xml index cabcefc3..0bce8831 100644 --- a/folkmq-lang-java/folkmq-parent/pom.xml +++ b/folkmq-lang-java/folkmq-parent/pom.xml @@ -6,7 +6,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 pom ${project.artifactId} @@ -18,8 +18,8 @@ UTF-8 1.8 - 1.2.3 - 2.4.5 + 1.2.4 + 2.4.6 3.2.88 2.7.1 diff --git a/folkmq-lang-java/folkmq-pro/pom.xml b/folkmq-lang-java/folkmq-pro/pom.xml index c885a3be..1a30deaf 100644 --- a/folkmq-lang-java/folkmq-pro/pom.xml +++ b/folkmq-lang-java/folkmq-pro/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-server/pom.xml b/folkmq-lang-java/folkmq-server/pom.xml index baf180c3..19200b9d 100644 --- a/folkmq-lang-java/folkmq-server/pom.xml +++ b/folkmq-lang-java/folkmq-server/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-server/src/main/java/org/noear/folkmq/server/pro/App.java b/folkmq-lang-java/folkmq-server/src/main/java/org/noear/folkmq/server/pro/App.java index a106049c..d1b1d34d 100644 --- a/folkmq-lang-java/folkmq-server/src/main/java/org/noear/folkmq/server/pro/App.java +++ b/folkmq-lang-java/folkmq-server/src/main/java/org/noear/folkmq/server/pro/App.java @@ -1,5 +1,9 @@ package org.noear.folkmq.server.pro; +import org.noear.socketd.SocketD; +import org.noear.socketd.transport.java_websocket.WsNioProvider; +import org.noear.socketd.transport.netty.tcp.TcpNioProvider; +import org.noear.socketd.transport.netty.udp.UdpNioProvider; import org.noear.solon.Solon; import org.noear.solon.validation.ValidatorException; @@ -10,6 +14,14 @@ public class App { public static void main(String[] args) { Solon.start(App.class, args, app -> { + //手动注册(避免 spi 失效) + SocketD.registerServerProvider(new WsNioProvider()); + SocketD.registerClientProvider(new WsNioProvider()); + SocketD.registerServerProvider(new TcpNioProvider()); + SocketD.registerClientProvider(new TcpNioProvider()); + SocketD.registerServerProvider(new UdpNioProvider()); + SocketD.registerClientProvider(new UdpNioProvider()); + //启用安全停止 app.cfg().stopSafe(true); diff --git a/folkmq-lang-java/folkmq-solon/pom.xml b/folkmq-lang-java/folkmq-solon/pom.xml index b5f2f005..dfd21b3e 100644 --- a/folkmq-lang-java/folkmq-solon/pom.xml +++ b/folkmq-lang-java/folkmq-solon/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-test/pom.xml b/folkmq-lang-java/folkmq-test/pom.xml index 3044ecd0..17abac6d 100644 --- a/folkmq-lang-java/folkmq-test/pom.xml +++ b/folkmq-lang-java/folkmq-test/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-transport-java-tcp/pom.xml b/folkmq-lang-java/folkmq-transport-java-tcp/pom.xml index ff4e8012..bd43cb81 100644 --- a/folkmq-lang-java/folkmq-transport-java-tcp/pom.xml +++ b/folkmq-lang-java/folkmq-transport-java-tcp/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-transport-java-websocket/pom.xml b/folkmq-lang-java/folkmq-transport-java-websocket/pom.xml index 8a76520d..633169a8 100644 --- a/folkmq-lang-java/folkmq-transport-java-websocket/pom.xml +++ b/folkmq-lang-java/folkmq-transport-java-websocket/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-transport-netty/pom.xml b/folkmq-lang-java/folkmq-transport-netty/pom.xml index a1db3b49..0d7d0a2c 100644 --- a/folkmq-lang-java/folkmq-transport-netty/pom.xml +++ b/folkmq-lang-java/folkmq-transport-netty/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq-transport-smartsocket/pom.xml b/folkmq-lang-java/folkmq-transport-smartsocket/pom.xml index e3bb509a..68f8e31f 100644 --- a/folkmq-lang-java/folkmq-transport-smartsocket/pom.xml +++ b/folkmq-lang-java/folkmq-transport-smartsocket/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq/pom.xml b/folkmq-lang-java/folkmq/pom.xml index 46bed021..3d3b9063 100644 --- a/folkmq-lang-java/folkmq/pom.xml +++ b/folkmq-lang-java/folkmq/pom.xml @@ -7,7 +7,7 @@ org.noear folkmq-parent - 1.2.3 + 1.2.4 ../folkmq-parent/pom.xml diff --git a/folkmq-lang-java/folkmq/src/main/java/org/noear/folkmq/FolkMQ.java b/folkmq-lang-java/folkmq/src/main/java/org/noear/folkmq/FolkMQ.java index beedb28e..f3c443d4 100644 --- a/folkmq-lang-java/folkmq/src/main/java/org/noear/folkmq/FolkMQ.java +++ b/folkmq-lang-java/folkmq/src/main/java/org/noear/folkmq/FolkMQ.java @@ -28,7 +28,7 @@ public static String versionCodeAsString() { * 获取版本名称 */ public static String versionName() { - return "1.2.3"; + return "1.2.4"; } /** diff --git a/folkmq-lang-js/folkmq-test/demo02-node-ws/package.json b/folkmq-lang-js/folkmq-test/demo02-node-ws/package.json index 93aa0671..5650d3d2 100644 --- a/folkmq-lang-js/folkmq-test/demo02-node-ws/package.json +++ b/folkmq-lang-js/folkmq-test/demo02-node-ws/package.json @@ -3,8 +3,6 @@ "description": "FolkMQ Node Test Project", "author": "noear", "dependencies": { - "@noear/socket.d": "2.4.5", - "@noear/folkmq": "1.2.3", - "ws": "^8.16.0" + "@noear/folkmq": "1.2.4" } } diff --git a/folkmq-lang-js/folkmq/package.json b/folkmq-lang-js/folkmq/package.json index 1a8254e5..e9692701 100644 --- a/folkmq-lang-js/folkmq/package.json +++ b/folkmq-lang-js/folkmq/package.json @@ -12,6 +12,6 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@noear/socket.d": "2.4.5" + "@noear/socket.d": "2.4.6" } } diff --git a/folkmq-lang-js/folkmq/src/FolkMQ.ts b/folkmq-lang-js/folkmq/src/FolkMQ.ts index c212ba9b..962736f7 100644 --- a/folkmq-lang-js/folkmq/src/FolkMQ.ts +++ b/folkmq-lang-js/folkmq/src/FolkMQ.ts @@ -25,7 +25,7 @@ export class FolkMQ { * 获取版本 */ static versionName(): string { - return "1.2.3"; + return "1.2.4"; } /** diff --git a/folkmq-lang-js/folkmq/webpack.md b/folkmq-lang-js/folkmq/webpack.md new file mode 100644 index 00000000..e9e49e7f --- /dev/null +++ b/folkmq-lang-js/folkmq/webpack.md @@ -0,0 +1,47 @@ + +### 1、打包流程 + +* 完成 ts 编译(多个文件) +* 通过 webpack (mode=production)打包成一个 js 文件(socket.d.js) +* 发布到 npm + +压缩工具(production 后,不需要了) + +https://www.wetools.com/js-compress/iYZtYekyTx3sWeGAA6jFE4GjKKnBBzNt + +发布说明 + +https://www.jb51.net/article/278264.htm + +### 2、webpack 安装参考 + +* 全局安装 + +``` +cnpm i -g webpack +cnpm i -g webpack-cli +``` + +* 项目安装 + +``` +cnpm i -D webpack +cnpm i -D webpack-cli +``` + +* 发包 + +``` +npm publish +``` + + +```javascript + +/*! + * FolkMQ v1.2.4 + * (c) 2023-2024 noear.org + * Released under the LGPL-2.1 License. + */ + +``` \ No newline at end of file diff --git a/folkmq-lang-js/release/folkmq.js b/folkmq-lang-js/release/folkmq.js new file mode 100644 index 00000000..6e95e789 --- /dev/null +++ b/folkmq-lang-js/release/folkmq.js @@ -0,0 +1,6 @@ +/*! + * FolkMQ v1.2.4 + * (c) 2023-2024 noear.org + * Released under the LGPL-2.1 License. + */ +var e={1625:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FolkMQ=void 0;const n=s(5865),r=s(7781),i=s(1420),a=s(3951),o=s(3306);class l{static versionCode(){return 2}static versionCodeAsString(){return l.versionCode().toString()}static versionName(){return"1.2.4"}static createClient(e){return new r.MqClientDefault(e)}static newRouter(e){return new i.MqRouter(e)}static newMessage(e){return new n.MqMessage(e)}static newAlarm(e){return new a.MqAlarm(e)}static newEntity(e){return o.SocketD.newEntity(e)}}t.FolkMQ=l},3951:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqAlarm=void 0;const n=s(8416);class r extends n.StringEntity{constructor(e){super(e)}}t.MqAlarm=r},7781:function(e,t,s){var n=this&&this.__awaiter||function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.MqClientDefault=void 0;const r=s(6769),i=s(9820),a=s(3306),o=s(5042),l=s(7173),u=s(6329),c=s(1625),h=s(8098),_=s(8380),d=s(4566),g=s(8385),M=s(3951);t.MqClientDefault=class{constructor(e){this._subscriptionMap=new Map,this._autoAcknowledge=!0,this._urls=e instanceof Array?e:[e],this._clientListener=new r.MqClientListener(this)}name(){return this._name}nameAs(e){return this._name=e,this}connect(){return n(this,void 0,void 0,(function*(){let e=new Array;for(let t of this._urls){t=t.replace("folkmq:ws://","sd:ws://"),t=t.replace("folkmq://","sd:tcp://");for(let s of t.split(","))this._name&&(s=s.includes("?")?s+"&@="+this._name:s+"?@="+this._name),e.push(s)}return this._clientSession=yield a.SocketD.createClusterClient(e).config((e=>{e.metaPut(o.MqConstants.FOLKMQ_VERSION,c.FolkMQ.versionCodeAsString()).heartbeatInterval(6e3).ioThreads(1).codecThreads(1).exchangeThreads(1),this._clientConfigHandler&&this._clientConfigHandler(e)})).listen(this._clientListener).open(),this}))}disconnect(){this._clientSession.close()}config(e){return this._clientConfigHandler=e,this}autoAcknowledge(e){return this._autoAcknowledge=e,this}subscribe(e,t,s,n){null==t&&(t=this.name()),null==s&&(s=this._autoAcknowledge),_.MqAssert.requireNonNull(e,"Param 'topic' can't be null"),_.MqAssert.requireNonNull(t,"Param 'consumerGroup' can't be null"),_.MqAssert.requireNonNull(n,"Param 'consumerHandler' can't be null"),_.MqAssert.assertMeta(e,"topic"),_.MqAssert.assertMeta(t,"consumerGroup");let r=new i.MqSubscription(e,t,s,n);if(this._subscriptionMap.set(r.getQueueName(),r),null!=this._clientSession)for(let s of this._clientSession.getSessionAll()){let n=a.SocketD.newEntity("").metaPut(o.MqConstants.MQ_META_TOPIC,r.getTopic()).metaPut(o.MqConstants.MQ_META_CONSUMER_GROUP,r.getConsumerGroup()).at(o.MqConstants.BROKER_AT_SERVER_ALL);s.sendAndRequest(o.MqConstants.MQ_EVENT_SUBSCRIBE,n,3e4).await(),console.info(`Client subscribe successfully: ${e}#${t}, sessionId=${s.sessionId()}`)}}unsubscribe(e,t){null==t&&(t=this.name()),_.MqAssert.requireNonNull(e,"Param 'topic' can't be null"),_.MqAssert.requireNonNull(t,"Param 'consumerGroup' can't be null"),_.MqAssert.assertMeta(e,"topic"),_.MqAssert.assertMeta(t,"consumerGroup");let s=e+o.MqConstants.SEPARATOR_TOPIC_CONSUMER_GROUP+t;if(this._subscriptionMap.delete(s),null!=this._clientSession)for(let s of this._clientSession.getSessionAll()){let n=a.SocketD.newEntity("").metaPut(o.MqConstants.MQ_META_TOPIC,e).metaPut(o.MqConstants.MQ_META_CONSUMER_GROUP,t).at(o.MqConstants.BROKER_AT_SERVER_ALL);s.sendAndRequest(o.MqConstants.MQ_EVENT_UNSUBSCRIBE,n,3e4).await(),console.info(`Client unsubscribe successfully: ${e}#${t}, sessionId=${s.sessionId()}`)}}publish(e,t){return n(this,void 0,void 0,(function*(){if(_.MqAssert.requireNonNull(e,"Param 'topic' can't be null"),_.MqAssert.requireNonNull(t,"Param 'message' can't be null"),_.MqAssert.assertMeta(e,"topic"),null==this._clientSession)throw new l.SocketDConnectionException("Not connected!");let s=this._clientSession.getSessionAny(this.diversionOrNull(e,t));if(null==s||0==s.isValid())throw new l.SocketDException("No session is available!");let n=u.MqUtils.getOf(s).publishEntityBuild(e,t);if(t.getQos()>0){let e=yield s.sendAndRequest(o.MqConstants.MQ_EVENT_PUBLISH,n).await();if(1!=parseInt(e.metaOrDefault(o.MqConstants.MQ_META_CONFIRM,"0"))){let t="Client message publish confirm failed: "+e.dataAsString();throw new h.FolkmqException(t)}}else s.send(o.MqConstants.MQ_EVENT_PUBLISH,n)}))}unpublish(e,t){return n(this,void 0,void 0,(function*(){if(_.MqAssert.requireNonNull(e,"Param 'topic' can't be null"),_.MqAssert.requireNonNull(t,"Param 'tid' can't be null"),_.MqAssert.assertMeta(e,"topic"),_.MqAssert.assertMeta(t,"tid"),null==this._clientSession)throw new l.SocketDConnectionException("Not connected!");let s=this._clientSession.getSessionAny(null);if(null==s||0==s.isValid())throw new l.SocketDException("No session is available!");let n=a.SocketD.newEntity("").metaPut(o.MqConstants.MQ_META_TOPIC,e).metaPut(o.MqConstants.MQ_META_TID,t).at(o.MqConstants.BROKER_AT_SERVER_ALL),r=yield s.sendAndRequest(o.MqConstants.MQ_EVENT_UNPUBLISH,n).await();if(1!=parseInt(r.metaOrDefault(o.MqConstants.MQ_META_CONFIRM,"0"))){let e="Client message unpublish confirm failed: "+r.dataAsString();throw new h.FolkmqException(e)}}))}listen(e){if(!this._name)throw new Error("Client 'name' can't be empty");this._listenHandler=e}send(e,t,s){if(!this._name)throw new Error("Client 'name' can't be empty");if(_.MqAssert.requireNonNull(t,"Param 'toName' can't be null"),_.MqAssert.requireNonNull(e,"Param 'message' can't be null"),_.MqAssert.assertMeta(t,"toName"),null==this._clientSession)throw new l.SocketDConnectionException("Not connected!");let n=this._clientSession.getSessionAny(null);if(null==n||0==n.isValid())throw new l.SocketDException("No session is available!");e.internalSender(this.name());let r=u.MqUtils.getOf(n).publishEntityBuild("",e);return r.putMeta(d.MqMetasV2.MQ_META_CONSUMER_GROUP,t),r.at(t),e.getQos()>0?n.sendAndRequest(o.MqConstants.MQ_EVENT_REQUEST,r,s):(n.send(o.MqConstants.MQ_EVENT_REQUEST,r),null)}transactionCheckback(e){return null!=e&&(this._transactionCheckback=e),this}newTransaction(){if(!this._name)throw new Error("Client 'name' can't be empty");return new g.MqTransactionImpl(this)}publish2(e,t,s){return n(this,void 0,void 0,(function*(){if(null==t||0==t.length)return;if(null==this._clientSession)throw new l.SocketDConnectionException("Not connected!");let n=this._clientSession.getSessionAny(e);if(null==n||0==n.isValid())throw new l.SocketDException("No session is available!");let r=a.SocketD.newEntity(t.join(",")).metaPut(o.MqConstants.MQ_META_ROLLBACK,s?"1":"0").at(o.MqConstants.BROKER_AT_SERVER_HASH),i=yield n.sendAndRequest(o.MqConstants.MQ_EVENT_PUBLISH2,r).await();if(1!=parseInt(i.metaOrDefault(o.MqConstants.MQ_META_CONFIRM,"0"))){let e="Client message publish2 confirm failed: "+i.dataAsString();throw new h.FolkmqException(e)}}))}reply(e,t,s,n,r){s.getQos()>0&&e.isValid()&&(null==r&&(r=a.SocketD.newEntity()),r instanceof M.MqAlarm?e.sendAlarm(t,r.dataAsString()):(r.putMeta(o.MqConstants.MQ_META_ACK,n?"1":"0"),e.replyEnd(t,r)))}diversionOrNull(e,t){return t.isTransaction()?t.getTmid():t.isSequence()?e:null}getSubscription(e,t){let s=e+o.MqConstants.SEPARATOR_TOPIC_CONSUMER_GROUP+t;return this._subscriptionMap.get(s)}getSubscriptionAll(){return new Set(this._subscriptionMap.values())}getSubscriptionSize(){return this._subscriptionMap.size}close(){this._clientSession.close()}}},6769:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqClientListener=void 0;const n=s(8350),r=s(5042),i=s(3306),a=s(7173),o=s(8652);class l extends n.EventListener{constructor(e){super(),this._client=e,this.doOn(r.MqConstants.MQ_EVENT_DISTRIBUTE,((t,s)=>{try{let n=new o.MqMessageReceivedImpl(e,t,s);this.onReceive(t,s,n,!1)}catch(e){console.warn("Client consume handle error, sid="+s.sid(),e)}})),this.doOn(r.MqConstants.MQ_EVENT_REQUEST,((t,s)=>{try{let n=new o.MqMessageReceivedImpl(e,t,s);this.onReceive(t,s,n,!0)}catch(e){console.warn("Client consume handle error, sid="+s.sid(),e)}}))}onReceive(e,t,s,n){if(n)try{s.isTransaction()?null!=this._client._transactionCheckback?this._client._transactionCheckback(s):e.sendAlarm(t,"Client no checkback handler!"):null!=this._client._listenHandler?this._client._listenHandler(s):e.sendAlarm(t,"Client no request handler!")}catch(n){try{e.isValid()&&e.sendAlarm(t,"Client request handle error:"+n),console.warn("Client request handle error, tid="+s.getTid(),n)}catch(e){console.warn("Client request handle error, tid="+s.getTid(),n)}}else{let n=this._client.getSubscription(s.getTopic(),s.getConsumerGroup());try{null!=n?(n.consume(s),n.isAutoAck()&&this._client.reply(e,t,s,!0,null)):this._client.reply(e,t,s,!1,null)}catch(r){try{null!=n?n.isAutoAck()&&this._client.reply(e,t,s,!1,null):this._client.reply(e,t,s,!1,null),console.warn("Client consume handle error, tid="+s.getTid(),r)}catch(e){console.warn("Client consume handle error, tid="+s.getTid(),r)}}}}onOpen(e){if(super.onOpen(e),console.info("Client session opened, sessionId="+e.sessionId()),0==this._client.getSubscriptionSize())return;let t=new Map;for(let e of this._client.getSubscriptionAll()){let s=t.get(e.getTopic());null==s&&(s=new Set,t.set(e.getTopic(),s)),s.add(e.getQueueName())}let s=JSON.stringify(t),n=i.SocketD.newEntity(s).metaPut(r.MqConstants.MQ_META_BATCH,"1").metaPut("@",r.MqConstants.BROKER_AT_SERVER);e.sendAndRequest(r.MqConstants.MQ_EVENT_SUBSCRIBE,n).await(),console.info("Client onOpen batch subscribe successfully, sessionId="+e.sessionId())}onClose(e){super.onClose(e),console.info("Client session closed, sessionId="+e.sessionId())}onError(e,t){super.onError(e,t),a.SocketDAlarmException,console.warn("Client error, sessionId="+e.sessionId(),t)}}t.MqClientListener=l},5865:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMessage=void 0;const n=s(9762);t.MqMessage=class{constructor(e){this._sender=null,this._tag=null,this._scheduled=null,this._expiration=null,this._sequence=!1,this._qos=1,this._attrMap=new Map,this._tid=n.StrUtils.guid(),this._content=e}getSender(){return this._sender}getTid(){return this._tid}getTag(){return this._tag}getContent(){return this._content}getScheduled(){return this._scheduled}getExpiration(){return this._expiration}isTransaction(){return null!=this._transaction}isSequence(){return this._sequence}getQos(){return this._qos}tag(e){return this._tag=e,this}asJson(){return this.attr("Content-Type","application/json"),this}scheduled(e){return this._scheduled=e,this}expiration(e){return this._expiration=e,this}sequence(e){return this._sequence=e,this}transaction(e){return e&&(this._transaction=e,e.binding(this)),this}getTmid(){return null==this._transaction?null:this._transaction.tmid()}internalSender(e){return this._sender=e,this}qos(e){return this._qos=e,this}getAttr(e){return this._attrMap.get(e)||null}getAttrMap(){return this._attrMap}attr(e,t){return this._attrMap.set(e,t),this}}},8652:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMessageReceivedImpl=void 0;const n=s(5042),r=s(6329);t.MqMessageReceivedImpl=class{constructor(e,t,s){this._clientInternal=e,this._session=t,this._source=s,this._content=s.dataAsString();let n=r.MqUtils.getOf(s);this._sender=n.getSender(s),this._tid=n.getTid(s),this._tag=n.getTag(s),this._topic=n.getTopic(s),this._consumerGroup=n.getConsumerGroup(s),this._qos=n.getQos(s),this._times=n.getTimes(s),this._sequence=n.isSequence(s),this._transaction=n.isTransaction(s);let i=n.getExpiration(s);this._expiration=0==i?null:new Date(i)}getSource(){return this._source}getSender(){return this._sender}getTid(){return this._tid}getTag(){return this._tag}getTopic(){return this._topic}getConsumerGroup(){return this._consumerGroup}getContent(){return this._content}getQos(){return this._qos}getAttr(e){return this._source.meta(n.MqConstants.MQ_ATTR_PREFIX+e)}getExpiration(){return this._expiration}isTransaction(){return this._transaction}isSequence(){return this._sequence}getTimes(){return this._times}acknowledge(e){this._clientInternal.reply(this._session,this._source,this,e,null)}response(e){this._clientInternal.reply(this._session,this._source,this,!0,e)}toString(){return"MqMessageReceived{tid='"+this._tid+"', tag='"+this._tag+"', topic='"+this._topic+"', content='"+this._content+"'}"}}},1420:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqRouter=void 0,t.MqRouter=class{constructor(e){this._mappingMap=new Map,this._mappingHandler=e}doOn(e,t){return this._mappingMap.set(e,t),this}doOnConsume(e){return this._consumeHandler=e,this}consume(e){null!=this._consumeHandler&&this._consumeHandler(e);let t=this._mappingHandler(e),s=this._mappingMap.get(t);null!=s&&s(e)}}},9820:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqSubscription=void 0;const n=s(5042);t.MqSubscription=class{constructor(e,t,s,r){this._topic=e,this._consumerGroup=t,this._autoAck=s,this._queueName=e+n.MqConstants.SEPARATOR_TOPIC_CONSUMER_GROUP+t,this._consumeHandler=r}getTopic(){return this._topic}getConsumerGroup(){return this._consumerGroup}isAutoAck(){return this._autoAck}getQueueName(){return this._queueName}consume(e){this._consumeHandler(e)}}},8385:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqTransactionImpl=void 0;const n=s(9762);t.MqTransactionImpl=class{constructor(e){this._client=e,this._tidAry=new Array,this._tmid=n.StrUtils.guid()}tmid(){return this._tmid}binding(e){this._tidAry.push(e.getTid()),e.internalSender(this._client.name())}commit(){this._client.publish2(this._tmid,this._tidAry,!1)}rollback(){this._client.publish2(this._tmid,this._tidAry,!0)}}},8380:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqAssert=void 0;class s{static requireNonNull(e,t){if(!e)throw new Error(t);return e}static assertMeta(e,t){s.assertMetaSymbols(e,t,"?","?"),s.assertMetaSymbols(e,t,"&","&"),s.assertMetaSymbols(e,t,"=","="),s.assertMetaSymbols(e,t,"!","!"),s.assertMetaSymbols(e,t,"@","@"),s.assertMetaSymbols(e,t,"#","#"),s.assertMetaSymbols(e,t,"$","$"),s.assertMetaSymbols(e,t,"%","%"),s.assertMetaSymbols(e,t,"^","^"),s.assertMetaSymbols(e,t,"*","*")}static assertMetaSymbols(e,t,s,n){if(e.indexOf(s)>=0)throw new Error("Param '"+t+"' can't have symbols: '"+n+"'")}}t.MqAssert=s},5042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqConstants=void 0;class s{}t.MqConstants=s,s.FOLKMQ_VERSION="folkmq-version",s.MQ_META_TID="mq.tid",s.MQ_META_TOPIC="mq.topic",s.MQ_META_CONSUMER_GROUP="mq.consumer",s.MQ_META_ACK="mq.ack",s.MQ_META_CONFIRM="mq.confirm",s.MQ_META_BATCH="mq.batch",s.MQ_META_ROLLBACK="mq.rollback",s.MQ_EVENT_SUBSCRIBE="mq.event.subscribe",s.MQ_EVENT_UNSUBSCRIBE="mq.event.unsubscribe",s.MQ_EVENT_PUBLISH="mq.event.publish",s.MQ_EVENT_PUBLISH2="mq.event.publish2",s.MQ_EVENT_UNPUBLISH="mq.event.unpublish",s.MQ_EVENT_DISTRIBUTE="mq.event.distribute",s.MQ_EVENT_REQUEST="mq.event.request",s.MQ_EVENT_SAVE="mq.event.save",s.MQ_EVENT_JOIN="mq.event.join",s.MQ_API="mq.api",s.API_NAME="api.name",s.API_TOKEN="api.token",s.ADMIN_PREFIX="admin.",s.ADMIN_VIEW_QUEUE="admin.view.queue",s.ADMIN_QUEUE_FORCE_DELETE="admin.queue.force.delete",s.ADMIN_QUEUE_FORCE_CLEAR="admin.queue.force.clear",s.ADMIN_QUEUE_FORCE_DISTRIBUTE="admin.queue.force.distribute",s.PARAM_ACCESS_KEY="ak",s.PARAM_ACCESS_SECRET_KEY="sk",s.SEPARATOR_TOPIC_CONSUMER_GROUP="#",s.BROKER_AT_SERVER="folkmq-server",s.BROKER_AT_SERVER_HASH="folkmq-server!",s.BROKER_AT_SERVER_ALL="folkmq-server*",s.MQ_TRAN_CONSUMER_GROUP="!",s.MQ_ATTR_PREFIX="!",s.MAX_FRAGMENT_SIZE=1048576},2438:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMetasResolverV1=void 0;const n=s(3558),r=s(3306),i=s(5042),a=s(7285),o=s(9762),l=s(4566),u=s(7553);t.MqMetasResolverV1=class{version(){return 1}getSender(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_SENDER,"")}getTid(e){return e.metaOrDefault(u.MqMetasV1.MQ_META_TID,"")}getTag(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_TAG,"")}getTopic(e){return e.metaOrDefault(u.MqMetasV1.MQ_META_TOPIC,"")}getConsumerGroup(e){return e.metaOrDefault(u.MqMetasV1.MQ_META_CONSUMER_GROUP,"")}setConsumerGroup(e,t){e.putMeta(u.MqMetasV1.MQ_META_CONSUMER_GROUP,t)}getQos(e){return"0"==e.meta(u.MqMetasV1.MQ_META_QOS)?0:1}getTimes(e){return parseInt(e.metaOrDefault(u.MqMetasV1.MQ_META_TIMES,"0"))}setTimes(e,t){e.putMeta(u.MqMetasV1.MQ_META_TIMES,t.toString())}getExpiration(e){return parseInt(e.metaOrDefault(u.MqMetasV1.MQ_META_EXPIRATION,"0"))}setExpiration(e,t){null==t?e.delMeta(u.MqMetasV1.MQ_META_EXPIRATION):e.putMeta(u.MqMetasV1.MQ_META_EXPIRATION,t.toString())}getScheduled(e){return parseInt(e.metaOrDefault(u.MqMetasV1.MQ_META_SCHEDULED,"0"))}setScheduled(e,t){e.putMeta(u.MqMetasV1.MQ_META_SCHEDULED,t.toString())}isSequence(e){return"1"==e.metaOrDefault(u.MqMetasV1.MQ_META_SEQUENCE,"0")}isTransaction(e){return"1"==e.meta(l.MqMetasV2.MQ_META_TRANSACTION)}setTransaction(e,t){e.putMeta(l.MqMetasV2.MQ_META_TRANSACTION,t?"1":"0")}publishEntityBuild(e,t){const s=r.SocketD.newEntity(t.getContent());return s.metaPut(u.MqMetasV1.MQ_META_TID,t.getTid()),s.metaPut(u.MqMetasV1.MQ_META_TOPIC,e),s.metaPut(u.MqMetasV1.MQ_META_QOS,0==t.getQos()?"0":"1"),t.getTag()&&s.metaPut(l.MqMetasV2.MQ_META_TAG,t.getTag()),null==t.getScheduled()?s.metaPut(u.MqMetasV1.MQ_META_SCHEDULED,"0"):s.metaPut(u.MqMetasV1.MQ_META_SCHEDULED,t.getScheduled().getTime().toString()),null!=t.getExpiration()&&s.metaPut(u.MqMetasV1.MQ_META_EXPIRATION,t.getExpiration().getTime().toString()),t.isTransaction()&&s.metaPut(l.MqMetasV2.MQ_META_TRANSACTION,"1"),t.getSender()&&s.metaPut(l.MqMetasV2.MQ_META_SENDER,t.getSender()),t.isSequence()||t.isTransaction()?(s.at(i.MqConstants.BROKER_AT_SERVER_HASH),t.isSequence()&&s.metaPut(u.MqMetasV1.MQ_META_SEQUENCE,"1")):s.at(i.MqConstants.BROKER_AT_SERVER),t.getAttrMap().forEach(((e,t,n)=>{s.putMeta(i.MqConstants.MQ_ATTR_PREFIX+t,e)})),s}routingMessageBuild(e,t){let s=this.publishEntityBuild(e,t).at(i.MqConstants.BROKER_AT_SERVER);return(new n.MessageBuilder).flag(a.Flags.Message).sid(o.StrUtils.guid()).event(i.MqConstants.MQ_EVENT_PUBLISH).entity(s).build()}}},5457:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMetasResolverV2=void 0;const n=s(3558),r=s(3306),i=s(5042),a=s(7285),o=s(9762),l=s(4566),u=s(1625);t.MqMetasResolverV2=class{version(){return 2}getSender(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_SENDER,"")}getTid(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_TID,"")}getTag(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_TAG,"")}getTopic(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_TOPIC,"")}getConsumerGroup(e){return e.metaOrDefault(l.MqMetasV2.MQ_META_CONSUMER_GROUP,"")}setConsumerGroup(e,t){e.putMeta(l.MqMetasV2.MQ_META_CONSUMER_GROUP,t)}getQos(e){return"0"==e.meta(l.MqMetasV2.MQ_META_QOS)?0:1}getTimes(e){return parseInt(e.metaOrDefault(l.MqMetasV2.MQ_META_TIMES,"0"))}setTimes(e,t){e.putMeta(l.MqMetasV2.MQ_META_TIMES,t.toString())}getExpiration(e){return parseInt(e.metaOrDefault(l.MqMetasV2.MQ_META_EXPIRATION,"0"))}setExpiration(e,t){null==t?e.delMeta(l.MqMetasV2.MQ_META_EXPIRATION):e.putMeta(l.MqMetasV2.MQ_META_EXPIRATION,t.toString())}getScheduled(e){return parseInt(e.metaOrDefault(l.MqMetasV2.MQ_META_SCHEDULED,"0"))}setScheduled(e,t){e.putMeta(l.MqMetasV2.MQ_META_SCHEDULED,t.toString())}isSequence(e){return"1"==e.meta(l.MqMetasV2.MQ_META_SEQUENCE)}isTransaction(e){return"1"==e.meta(l.MqMetasV2.MQ_META_TRANSACTION)}setTransaction(e,t){e.putMeta(l.MqMetasV2.MQ_META_TRANSACTION,t?"1":"0")}publishEntityBuild(e,t){const s=r.SocketD.newEntity(t.getContent());return s.metaPut(l.MqMetasV2.MQ_META_TID,t.getTid()),s.metaPut(l.MqMetasV2.MQ_META_TOPIC,e),s.metaPut(l.MqMetasV2.MQ_META_QOS,0==t.getQos()?"0":"1"),t.getTag()&&s.metaPut(l.MqMetasV2.MQ_META_TAG,t.getTag()),null==t.getScheduled()?s.metaPut(l.MqMetasV2.MQ_META_SCHEDULED,"0"):s.metaPut(l.MqMetasV2.MQ_META_SCHEDULED,t.getScheduled().getTime().toString()),null!=t.getExpiration()&&s.metaPut(l.MqMetasV2.MQ_META_EXPIRATION,t.getExpiration().getTime().toString()),t.isTransaction()&&s.metaPut(l.MqMetasV2.MQ_META_TRANSACTION,"1"),t.getSender()&&s.metaPut(l.MqMetasV2.MQ_META_SENDER,t.getSender()),t.isSequence()||t.isTransaction()?(s.at(i.MqConstants.BROKER_AT_SERVER_HASH),t.isSequence()&&s.metaPut(l.MqMetasV2.MQ_META_SEQUENCE,"1")):s.at(i.MqConstants.BROKER_AT_SERVER),s.metaPut(l.MqMetasV2.MQ_META_VID,u.FolkMQ.versionCode().toString()),t.getAttrMap().forEach(((e,t,n)=>{s.putMeta(i.MqConstants.MQ_ATTR_PREFIX+t,e)})),s}routingMessageBuild(e,t){let s=this.publishEntityBuild(e,t).at(i.MqConstants.BROKER_AT_SERVER);return(new n.MessageBuilder).flag(a.Flags.Message).sid(o.StrUtils.guid()).event(i.MqConstants.MQ_EVENT_PUBLISH).entity(s).build()}}},7553:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMetasV1=void 0;class s{}t.MqMetasV1=s,s.MQ_META_TID="mq.tid",s.MQ_META_TOPIC="mq.topic",s.MQ_META_CONSUMER_GROUP="mq.consumer",s.MQ_META_SCHEDULED="mq.scheduled",s.MQ_META_EXPIRATION="mq.expiration",s.MQ_META_SEQUENCE="mq.sequence",s.MQ_META_QOS="mq.qos",s.MQ_META_TIMES="mq.times"},4566:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqMetasV2=void 0;class s{}t.MqMetasV2=s,s.MQ_META_TID="t0",s.MQ_META_VID="v0",s.MQ_META_SENDER="s0",s.MQ_META_TOPIC="t1",s.MQ_META_CONSUMER_GROUP="c1",s.MQ_META_SCHEDULED="s1",s.MQ_META_EXPIRATION="e1",s.MQ_META_SEQUENCE="s2",s.MQ_META_TRANSACTION="t4",s.MQ_META_QOS="q1",s.MQ_META_TIMES="t2",s.MQ_META_TAG="t5"},6329:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MqUtils=void 0;const n=s(3558),r=s(5042),i=s(5457),a=s(2438),o=s(4566);class l{static getV2(){return l.v2}static getOf(e){return null==e?l.v2:e instanceof n.MessageDefault?"1"==e.metaOrDefault(o.MqMetasV2.MQ_META_VID,"1")?l.v1:l.v2:"1"==e.handshake().paramOrDefault(r.MqConstants.FOLKMQ_VERSION,"1")?l.v1:l.v2}}t.MqUtils=l,l.v1=new a.MqMetasResolverV1,l.v2=new i.MqMetasResolverV2},8098:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FolkmqException=void 0;class s extends Error{constructor(e){super(e)}}t.FolkmqException=s},3306:(e,t,s)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SocketD=void 0;const r=s(2805),i=s(5935),a=s(3684),o=s(4294),l=s(8416),u=s(8350),c=s(7285),h=s(3863),_=s(2125),d=s(6992);class g{static version(){return"2.4.5"}static protocolVersion(){return"1.0"}static createServer(e){let t=this.createServerOrNull(e);if(null==t)throw new Error("No socketd server providers were found: "+e);return t}static createServerOrNull(e){r.Asserts.assertNull("schema",e);let t=n.serverProviderMap.get(e);return null==t?null:t.createServer(new h.ServerConfig(e))}static createClient(e){const t=this.createClientOrNull(e);if(null==t)throw new Error("No socketd client providers were found: "+e);return t}static createClientOrNull(e){r.Asserts.assertNull("serverUrl",e);const t=e.indexOf("://");if(t<2)throw new Error("The serverUrl invalid: "+e);const s=e.substring(0,t),n=this.clientProviderMap.get(s);if(null==n)return null;{const t=new i.ClientConfig(e);return n.createClient(t)}}static createClusterClient(e){return new a.ClusterClient(e)}static newEntity(e){return e?"[object String]"===toString.call(e)?new l.StringEntity(e.toString()):e instanceof File?new l.FileEntity(e):e instanceof ArrayBuffer||e instanceof Blob?(new l.EntityDefault).dataSet(e):new l.StringEntity(e.toString()):new l.EntityDefault}static newSimpleListener(){return new u.SimpleListener}static newEventListener(e){return new u.EventListener(e)}static newPathListener(e){return new u.PathListener(e)}static newPipelineListener(){return new u.PipelineListener}static newBrokerListener(){return new _.BrokerListener}static newBrokerFragmentHandler(){return new d.BrokerFragmentHandler}}t.SocketD=g,n=g,g.EntityMetas=c.EntityMetas,g.clientProviderMap=new Map,g.serverProviderMap=new Map,(()=>{const e=new o.WsProvider;for(const t of e.schemas())n.clientProviderMap.set(t,e);for(const t of e.schemas())n.serverProviderMap.set(t,e)})()},6992:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerFragmentHandler=void 0;const n=s(7460);class r extends n.FragmentHandlerDefault{aggrEnable(){return!1}}t.BrokerFragmentHandler=r},2125:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerListener=void 0;const n=s(7818),r=s(2974);class i extends n.BrokerListenerBase{onOpen(e){let t=e.name();this.addPlayer(t,e)}onClose(e){let t=e.name();this.removePlayer(t,e)}onMessage(e,t){let s=t.atName();if(s)if("*"==s){let s=this.getNameAll();if(null!=s&&s.size>0)for(let n of s)this.forwardToName(e,t,n)}else if(s.endsWith("*"))s=s.substring(0,s.length()-1),0==this.forwardToName(e,t,s)&&e.sendAlarm(t,"Broker don't have '@"+s+"' player");else{let n=this.getPlayerAny(s,e);null!=n?this.forwardToSession(e,t,n):e.sendAlarm(t,"Broker don't have '@"+s+"' session")}else e.sendAlarm(t,"Broker message require '@' meta")}forwardToName(e,t,s){let n=this.getPlayerAll(s);if(null!=n&&n.size>0){for(let s of n)s!=e&&(s.isValid()?this.forwardToSession(e,t,s):this.onClose(s));return!0}return!1}forwardToSession(e,t,s){t.isRequest()?s.sendAndRequest(t.event(),t,-1).thenReply((s=>{e.isValid()&&e.reply(t,s)})).thenError((s=>{e.isValid()&&r.RunUtils.runAndTry((()=>e.sendAlarm(t,s.message)))})):t.isSubscribe()?s.sendAndSubscribe(t.event(),t).thenReply((s=>{e.isValid()&&(s.isEnd()?e.replyEnd(t,s):e.reply(t,s))})).thenError((s=>{e.isValid()&&r.RunUtils.runAndTry((()=>e.sendAlarm(t,s.message)))})):s.send(t.event(),t)}onError(e,t){console.warn("Broker error",t)}}t.BrokerListener=i},7818:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrokerListenerBase=void 0;const n=s(3869);t.BrokerListenerBase=class{constructor(){this._sessionAll=new Map,this._playerSessions=new Map}getSessionAll(){return this._sessionAll.values()}getSessionAny(){return n.LoadBalancer.getAnyByPoll(new Set(this._sessionAll.values()))}getSessionCount(){return this._sessionAll.size}getNameAll(){return new Set(this._playerSessions.keys())}getPlayerCount(e){let t=this.getPlayerAll(e);return null==t?0:t.size}getPlayerAll(e){if(e){return this._playerSessions.get(e)||null}return null}getPlayerAny(e,t){return e?e.endsWith("!")?(e=e.substring(0,e.length-1),null==t?n.LoadBalancer.getAnyByPoll(this.getPlayerAll(e)):n.LoadBalancer.getAnyByHash(this.getPlayerAll(e),t.remoteAddress().address)):n.LoadBalancer.getAnyByPoll(this.getPlayerAll(e)):null}addPlayer(e,t){if(e){let s=this._playerSessions.get(e);s||(s=new Set,this._playerSessions.set(e,s)),s.add(t)}this._sessionAll.set(t.sessionId(),t)}removePlayer(e,t){if(e){let s=this.getPlayerAll(e);null!=s&&s.delete(t)}this._sessionAll.delete(t.sessionId())}}},3684:function(e,t,s){var n=this&&this.__awaiter||function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClusterClient=void 0;const r=s(8630),i=s(3306);t.ClusterClient=class{constructor(e){this._serverUrls=e instanceof Array?e:[e]}connectHandler(e){return this._connectHandler=e,this}heartbeatHandler(e){return this._heartbeatHandler=e,this}config(e){return this._configHandler=e,this}listen(e){return this._listener=e,this}open(){return n(this,void 0,void 0,(function*(){return this.openDo(!1)}))}openOrThow(){return n(this,void 0,void 0,(function*(){return this.openDo(!0)}))}openDo(e){return n(this,void 0,void 0,(function*(){const t=new Array;for(const s of this._serverUrls)for(let n of s.split(",")){if(n=n.trim(),!n)continue;const s=i.SocketD.createClient(n);this._listener&&s.listen(this._listener),this._configHandler&&s.config(this._configHandler),this._connectHandler&&s.connectHandler(this._connectHandler),this._heartbeatHandler&&s.heartbeatHandler(this._heartbeatHandler),e?t.push(yield s.openOrThow()):t.push(yield s.open())}return new r.ClusterClientSession(t)}))}}},8630:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClusterClientSession=void 0;const n=s(9762),r=s(7173),i=s(2974),a=s(3869);t.ClusterClientSession=class{constructor(e){this._sessionSet=new Set(e),this._sessionId=n.StrUtils.guid()}getSessionAll(){return this._sessionSet}getSessionAny(e){let t=null;if(t=e?a.LoadBalancer.getAnyByHash(this._sessionSet,e):a.LoadBalancer.getAnyByPoll(this._sessionSet),null==t)throw new r.SocketDException("No session is available!");return t}getSessionOne(){return this.getSessionAny(null)}isValid(){for(const e of this._sessionSet)if(e.isValid())return!0;return!1}isClosing(){for(const e of this._sessionSet)if(e.isClosing())return!0;return!1}sessionId(){return this._sessionId}reconnect(){for(const e of this._sessionSet)0==e.isValid()&&e.reconnect()}send(e,t){return this.getSessionAny(null).send(e,t)}sendAndRequest(e,t,s){return this.getSessionAny(null).sendAndRequest(e,t,s)}sendAndSubscribe(e,t,s){return this.getSessionAny(null).sendAndSubscribe(e,t,s)}close(){for(const e of this._sessionSet)i.RunUtils.runAndTry(e.close)}}},3869:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LoadBalancer=void 0;class s{static roundCounterGet(){let e=s.roundCounter++;return e>999999&&s.roundCounter,e}static hashcode(e){var t,s,n=0;if(0===e.length)return n;for(t=0,s=e.length;ts.roundCounterGet()))}static getAnyByHash(e,t){return s.getAny(e,(()=>s.hashcode(t)))}static getAny(e,t){if(null==e||0==e.size)return null;{let s=new Array;for(let t of e)t.isValid()&&!t.isClosing()&&s.push(t);return 0==s.length?null:1==s.length?s[0]:s[Math.abs(t())%s.length]}}static getFirst(e){if(null==e||0==e.length)return null;for(let t of e)if(t.isValid()&&!t.isClosing())return t;return null}}t.LoadBalancer=s,s.roundCounter=0},7173:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SocketDTimeoutException=t.SocketDSizeLimitException=t.SocketDConnectionException=t.SocketDCodecException=t.SocketDChannelException=t.SocketDAlarmException=t.SocketDException=void 0;class s extends Error{constructor(e){super(e)}}t.SocketDException=s,t.SocketDAlarmException=class extends s{constructor(e){super(e.entity().dataAsString()),this._alarm=e}getAlarm(){return this._alarm}},t.SocketDChannelException=class extends s{constructor(e){super(e)}},t.SocketDCodecException=class extends s{constructor(e){super(e)}},t.SocketDConnectionException=class extends s{constructor(e){super(e)}},t.SocketDSizeLimitException=class extends s{constructor(e){super(e)}},t.SocketDTimeoutException=class extends s{constructor(e){super(e)}}},7788:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientBase=void 0;const n=s(6322),r=s(6294),i=s(7285);t.ClientBase=class{constructor(e,t){this._config=e,this._assistant=t,this._processor=new n.ProcessorDefault}getAssistant(){return this._assistant}getConnectHandler(){return this._connectHandler}getHeartbeatHandler(){return this._heartbeatHandler}getHeartbeatInterval(){return this.getConfig().getHeartbeatInterval()}getConfig(){return this._config}getProcessor(){return this._processor}connectHandler(e){return null!=e&&(this._connectHandler=e),this}heartbeatHandler(e){return null!=e&&(this._heartbeatHandler=e),this}config(e){return null!=e&&e(this._config),this}listen(e){return null!=e&&this._processor.setListener(e),this}open(){return this.openDo(!1)}openOrThow(){return this.openDo(!0)}openDo(e){const t=this.createConnector(),s=new r.ClientChannel(this,t);return new Promise(((t,n)=>{s.connect().then((e=>{console.info("Socket.D client successfully connected!"),t(s.getSession())}),(r=>{e?(s.close(i.Constants.CLOSE2008_OPEN_FAIL),n(r)):(console.warn("Socket.D client Connection failed!"),t(s.getSession()))}))}))}}},6294:function(e,t,s){var n=this&&this.__awaiter||function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ClientChannel=void 0;const r=s(3338),i=s(7285),a=s(2805),o=s(7173),l=s(2974),u=s(7082),c=s(2770),h=s(5490);class _ extends r.ChannelBase{constructor(e,t){super(t.getConfig()),this._isConnecting=!1,this._client=e,this._connector=t,this._sessionShell=new u.SessionDefault(this),this._connectHandler=new h.ClientConnectHandlerDefault(e.getConnectHandler()),this._heartbeatHandler=new c.ClientHeartbeatHandlerDefault(e.getHeartbeatHandler()),this.initHeartbeat()}initHeartbeat(){this._heartbeatScheduledFuture&&clearInterval(this._heartbeatScheduledFuture),this._connector.autoReconnect()&&(this._heartbeatScheduledFuture=setInterval((()=>n(this,void 0,void 0,(function*(){try{yield this.heartbeatHandle()}catch(e){console.debug("Client channel heartbeat error",e)}}))),this._client.getHeartbeatInterval()))}heartbeatHandle(){return n(this,void 0,void 0,(function*(){if(this._real){if(null==this._real.getHandshake())return;if(a.Asserts.isClosedAndEnd(this._real))return console.debug(`Client channel is closed (pause heartbeat), sessionId=${this.getSession().sessionId()}`),void this.close(this._real.isClosed());if(this._real.isClosing())return}try{yield this.internalCheck(),this._heartbeatHandler.clientHeartbeat(this.getSession())}catch(e){if(e instanceof o.SocketDException)throw e;throw this._connector.autoReconnect()&&this.internalCloseIfError(),new o.SocketDChannelException(e)}}))}isValid(){return null!=this._real&&this._real.isValid()}isClosing(){return null!=this._real&&this._real.isClosing()}isClosed(){return null==this._real?0:this._real.isClosed()}getLiveTime(){return this._real?this._real.getLiveTime():0}getRemoteAddress(){return this._real?this._real.getRemoteAddress():null}getLocalAddress(){return this._real?this._real.getLocalAddress():null}send(e,t){a.Asserts.assertClosedAndEnd(this._real),this.internalCheck().then((s=>{if(this._real)try{this._real.send(e,t)}catch(e){t&&t.onError(e)}else{const e=new o.SocketDChannelException("Client channel is not connected");t&&t.onError(e)}}),(e=>{this._connector.autoReconnect()&&this.internalCloseIfError(),t&&t.onError(e)}))}retrieve(e,t){this._real.retrieve(e,t)}reconnect(){return n(this,void 0,void 0,(function*(){this.initHeartbeat(),yield this.internalCheck()}))}onError(e){this._real.onError(e)}close(e){l.RunUtils.runAndTry((()=>clearInterval(this._heartbeatScheduledFuture))),l.RunUtils.runAndTry((()=>this._connector.close())),this._real&&l.RunUtils.runAndTry((()=>this._real.close(e))),super.close(e)}getSession(){return this._sessionShell}connect(){return n(this,void 0,void 0,(function*(){if(!this._isConnecting){this._isConnecting=!0;try{null!=this._real&&this._real.close(i.Constants.CLOSE2002_RECONNECT),this._real=yield this._connectHandler.clientConnect(this._connector),this._real.setSession(this._sessionShell),this.setHandshake(this._real.getHandshake())}finally{this._isConnecting=!1}}}))}internalCloseIfError(){null!=this._real&&(this._real.close(i.Constants.CLOSE2001_ERROR),this._real=null)}internalCheck(){return n(this,void 0,void 0,(function*(){return(null==this._real||0==this._real.isValid())&&(yield this.connect(),!0)}))}}t.ClientChannel=_},5935:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConfig=void 0;const n=s(7267),r=s(9762);class i extends n.ConfigBase{constructor(e){super(!0),this._metaMap=new Map,e.startsWith("sd:")&&(e=e.substring(3)),this._url=e,this._linkUrl="sd:"+e;let t=r.StrUtils.parseUri(e);this._host=t.host,this._port=parseInt(t.port),this._schema=t.protocol,this._port<0&&(this._port=8602),this._connectTimeout=1e4,this._heartbeatInterval=2e4,this._autoReconnect=!0}getSchema(){return this._schema}getLinkUrl(){return this._linkUrl}getUrl(){return this._url}getHost(){return this._host}getPort(){return this._port}getMetaMap(){return this._metaMap}metaPut(e,t){return this._metaMap.set(e,t),this}getHeartbeatInterval(){return this._heartbeatInterval}heartbeatInterval(e){return this._heartbeatInterval=e,this}getConnectTimeout(){return this._connectTimeout}connectTimeout(e){return this._connectTimeout=e,this}isAutoReconnect(){return this._autoReconnect}autoReconnect(e){return this._autoReconnect=e,this}idleTimeout(e){return 0==this._autoReconnect?(this._idleTimeout=e,this):(this._idleTimeout=0,this)}toString(){return"ClientConfig{schema='"+this._schema+"', charset="+this._charset+", url='"+this._url+"', ioThreads="+this._ioThreads+", codecThreads="+this._codecThreads+", exchangeThreads="+this._exchangeThreads+", heartbeatInterval="+this._heartbeatInterval+", connectTimeout="+this._connectTimeout+", idleTimeout="+this._idleTimeout+", requestTimeout="+this._requestTimeout+", readBufferSize="+this._readBufferSize+", writeBufferSize="+this._writeBufferSize+", autoReconnect="+this._autoReconnect+", maxUdpSize="+this._maxUdpSize+"}"}}t.ClientConfig=i},5490:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConnectHandlerDefault=void 0,t.ClientConnectHandlerDefault=class{constructor(e){this._connectHandler=e}clientConnect(e){return this._connectHandler?this._connectHandler(e):e.connect()}}},1479:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientConnectorBase=void 0,t.ClientConnectorBase=class{constructor(e){this._client=e}getConfig(){return this._client.getConfig()}autoReconnect(){return this._client.getConfig().isAutoReconnect()}}},7321:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientHandshakeResult=void 0,t.ClientHandshakeResult=class{constructor(e,t){this._channel=e,this._throwable=t}getChannel(){return this._channel}getThrowable(){return this._throwable}}},2770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientHeartbeatHandlerDefault=void 0,t.ClientHeartbeatHandlerDefault=class{constructor(e){this._heartbeatHandler=e}clientHeartbeat(e){this._heartbeatHandler?this._heartbeatHandler(e):e.sendPing()}}},2805:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Asserts=void 0;const n=s(7285),r=s(7173);class i{static assertClosed(e){if(null!=e&&e.isClosed()>0)throw new r.SocketDChannelException("This channel is closed, sessionId="+e.getSession().sessionId())}static isClosedAndEnd(e){return e.isClosed()==n.Constants.CLOSE2009_USER||e.isClosed()==n.Constants.CLOSE2008_OPEN_FAIL}static assertClosedAndEnd(e){if(null!=e&&i.isClosedAndEnd(e))throw new r.SocketDChannelException("This channel is closed, sessionId="+e.getSession().sessionId())}static assertNull(e,t){if(null==t)throw new Error("The argument cannot be null: "+e)}static assertEmpty(e,t){if(!t)throw new Error("The argument cannot be empty: "+e)}static assertSize(e,t,s){if(t>s){const n=`This message ${e} size is out of limit ${s} (${t})`;throw new r.SocketDSizeLimitException(n)}}}t.Asserts=i},9612:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BlobBuffer=t.ByteBuffer=void 0,t.ByteBuffer=class{constructor(e){this._bufIdx=0,this._buf=e}remaining(){return this.size()-this.position()}position(){return this._bufIdx}size(){return this._buf.byteLength}reset(){this._bufIdx=0}getBytes(e,t){let s=this.remaining();if(s>e&&(s=e),s<=0)return!1;let n=this._bufIdx+s,r=this._buf.slice(this._bufIdx,n);return this._bufIdx=n,t(r),!0}getBlob(){return null}getArray(){return this._buf}},t.BlobBuffer=class{constructor(e){this._bufIdx=0,this._buf=e}remaining(){return this._buf.size-this._bufIdx}position(){return this._bufIdx}size(){return this._buf.size}reset(){this._bufIdx=0}getBytes(e,t){let s=this.remaining();if(s>e&&(s=e),s<=0)return!1;let n=this._bufIdx+s,r=this._buf.slice(this._bufIdx,n),i=new FileReader;return i.onload=e=>{e.target&&t(e.target.result)},i.readAsArrayBuffer(r),this._bufIdx=n,!0}getBlob(){return this._buf}getArray(){return null}}},3338:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelBase=void 0;const n=s(4419),r=s(7285);t.ChannelBase=class{constructor(e){this._config=e,this._attachments=new Map}getAttachment(e){return this._attachments.get(e)}putAttachment(e,t){null==t?this._attachments.delete(e):this._attachments.set(e,t)}close(e){e>r.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&this._attachments.clear()}getConfig(){return this._config}setHandshake(e){this._handshake=e}getHandshake(){return this._handshake}sendConnect(e,t){this.send(n.Frames.connectFrame(this.getConfig().getIdGenerator().generate(),e,t),null)}sendConnack(){this.send(n.Frames.connackFrame(this.getHandshake()),null)}sendPing(){this.send(n.Frames.pingFrame(),null)}sendPong(){this.send(n.Frames.pongFrame(),null)}sendClose(e){this.send(n.Frames.closeFrame(e),null)}sendAlarm(e,t){this.send(n.Frames.alarmFrame(e,t),null)}}},4851:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ChannelDefault=void 0;const n=s(4419),r=s(3558),i=s(7285),a=s(3338),o=s(7082);class l extends a.ChannelBase{constructor(e,t){super(t.getConfig()),this._liveTime=0,this._closeCode=0,this._source=e,this._processor=t.getProcessor(),this._assistant=t.getAssistant(),this._streamManger=t.getConfig().getStreamManger()}onOpenFuture(e){this._onOpenFuture=e}doOpenFuture(e,t){this._onOpenFuture&&this._onOpenFuture(e,t)}isValid(){return 0==this.isClosed()&&this._assistant.isValid(this._source)}isClosing(){return this._closeCode==i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING}isClosed(){return this._closeCode>i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING?this._closeCode:0}config(){return this._config}sendPing(){this.send(n.Frames.pingFrame(),null)}sendPong(){this.send(n.Frames.pongFrame(),null)}getRemoteAddress(){return this._assistant.getRemoteAddress(this._source)}getLocalAddress(){return this._assistant.getLocalAddress(this._source)}send(e,t){if(this.getConfig().clientMode()||console.debug("S-SEN:"+e),e.message()){const s=e.message();if(null!=t&&this._streamManger.addStream(s.sid(),t),null!=s.entity())return s.dataSize()>this.getConfig().getFragmentSize()&&s.putMeta(i.EntityMetas.META_DATA_LENGTH,s.dataSize().toString()),void this.getConfig().getFragmentHandler().spliFragment(this,t,s,(t=>{const i=new n.Frame(e.flag(),(new r.MessageBuilder).flag(e.flag()).sid(s.sid()).event(s.event()).entity(t).build());this._assistant.write(this._source,i)}))}this._assistant.write(this._source,e),null!=t&&t.onProgress(!0,1,1)}retrieve(e,t){t?((t.demands()i.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&(setTimeout((()=>{this._assistant.close(this._source)}),100),console.debug(`${this.getConfig().getRoleName()} channel closed, sessionId=${this.getSession().sessionId()}`))}catch(e){console.warn(`${this.getConfig().getRoleName()} channel close error, sessionId=${this.getSession().sessionId()}`,e)}}}t.ChannelDefault=l},3321:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ArrayBufferCodecWriter=t.ArrayBufferCodecReader=void 0,t.ArrayBufferCodecReader=class{constructor(e){this._buf=e,this._bufView=new DataView(e),this._bufViewIdx=0}getByte(){if(this._bufViewIdx>=this._buf.byteLength)return-1;const e=this._bufView.getInt8(this._bufViewIdx);return this._bufViewIdx+=1,e}getBytes(e,t,s){const n=new DataView(e),r=t+s;for(let e=t;e=this._buf.byteLength);e++)n.setInt8(e,this._bufView.getInt8(this._bufViewIdx)),this._bufViewIdx++}getInt(){if(this._bufViewIdx>=this._buf.byteLength)return-1;const e=this._bufView.getInt32(this._bufViewIdx);return this._bufViewIdx+=4,e}peekByte(){return this.remaining()>0?this._bufView.getInt8(this._bufViewIdx):-1}skipBytes(e){this._bufViewIdx=this.position()+e}remaining(){return this._buf.byteLength-this._bufViewIdx}position(){return this._bufViewIdx}size(){return this._buf.byteLength}reset(){this._bufViewIdx=0}},t.ArrayBufferCodecWriter=class{constructor(e){this._buf=new ArrayBuffer(e),this._bufView=new DataView(this._buf),this._bufViewIdx=0}putBytes(e){const t=new DataView(e),s=t.byteLength;for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.CodecDefault=void 0;const n=s(4419),r=s(9762),i=s(2805),a=s(7285),o=s(3558),l=s(8416);t.CodecDefault=class{constructor(e){this._config=e}write(e,t){if(e.message()){const s=r.StrUtils.strToBuf(e.message().sid(),this._config.getCharset()),n=r.StrUtils.strToBuf(e.message().event(),this._config.getCharset()),o=r.StrUtils.strToBuf(e.message().metaString(),this._config.getCharset()),l=8+s.byteLength+n.byteLength+o.byteLength+e.message().dataSize()+6;i.Asserts.assertSize("sid",s.byteLength,a.Constants.MAX_SIZE_SID),i.Asserts.assertSize("event",n.byteLength,a.Constants.MAX_SIZE_EVENT),i.Asserts.assertSize("metaString",o.byteLength,a.Constants.MAX_SIZE_META_STRING),i.Asserts.assertSize("data",e.message().dataSize(),a.Constants.MAX_SIZE_DATA);const u=t(l);return u.putInt(l),u.putInt(e.flag()),u.putBytes(s),u.putChar("\n".charCodeAt(0)),u.putBytes(n),u.putChar("\n".charCodeAt(0)),u.putBytes(o),u.putChar("\n".charCodeAt(0)),u.putBytes(e.message().data().getArray()),u.flush(),u}{const s=8,n=t(s);return n.putInt(s),n.putInt(e.flag()),n.flush(),n}}read(e){const t=e.getInt();if(t>e.remaining()+4)return null;const s=e.getInt();if(8==t)return new n.Frame(a.Flags.of(s),null);{const r=Math.min(a.Constants.MAX_SIZE_META_STRING,e.remaining()),i=new ArrayBuffer(r),u=this.decodeString(e,i,a.Constants.MAX_SIZE_SID),c=this.decodeString(e,i,a.Constants.MAX_SIZE_EVENT),h=this.decodeString(e,i,a.Constants.MAX_SIZE_META_STRING),_=t-e.position();let d;if(_>a.Constants.MAX_SIZE_DATA){d=new ArrayBuffer(a.Constants.MAX_SIZE_DATA),e.getBytes(d,0,a.Constants.MAX_SIZE_DATA);for(let t=_-a.Constants.MAX_SIZE_DATA;t>0;t--)e.getByte()}else d=new ArrayBuffer(_),_>0&&e.getBytes(d,0,_);const g=(new o.MessageBuilder).flag(a.Flags.of(s)).sid(u).event(c).entity((new l.EntityDefault).dataSet(d).metaStringSet(h)).build();return new n.Frame(g.flag(),g)}}decodeString(e,t,s){const n=new DataView(t);let i=0;for(;;){const t=e.getByte();if(0==t&&10==e.peekByte()){e.skipBytes(1);break}s>0&&s<=i||(n.setInt8(i,t),i++)}return i<1?"":r.StrUtils.bufToStr(t,0,i,this._config.getCharset())}}},7267:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConfigBase=void 0;const n=s(5740),r=s(8780),i=s(7460),a=s(7285),o=s(2805),l=s(4829);t.ConfigBase=class{constructor(e){this._clientMode=e,this._streamManger=new n.StreamMangerDefault(this),this._codec=new l.CodecDefault(this),this._charset="utf-8",this._idGenerator=new r.GuidGenerator,this._fragmentHandler=new i.FragmentHandlerDefault,this._fragmentSize=a.Constants.MAX_SIZE_DATA,this._ioThreads=1,this._codecThreads=2,this._exchangeThreads=4*this._codecThreads,this._readBufferSize=512,this._writeBufferSize=512,this._idleTimeout=0,this._requestTimeout=1e4,this._streamTimeout=72e5,this._maxUdpSize=2048}clientMode(){return this._clientMode}getStreamManger(){return this._streamManger}getRoleName(){return this.clientMode()?"Client":"Server"}getCharset(){return this._charset}charset(e){return this._charset=e,this}getCodec(){return this._codec}getIdGenerator(){return this._idGenerator}idGenerator(e){return o.Asserts.assertNull("idGenerator",e),this._idGenerator=e,this}getFragmentHandler(){return this._fragmentHandler}fragmentHandler(e){return o.Asserts.assertNull("fragmentHandler",e),this._fragmentHandler=e,this}getFragmentSize(){return this._fragmentSize}fragmentSize(e){if(e>a.Constants.MAX_SIZE_DATA)throw new Error("The parameter fragmentSize cannot > 16m");if(e{Object.defineProperty(t,"__esModule",{value:!0}),t.EntityMetas=t.Flags=t.Constants=void 0;const n=s(9612);t.Constants={DEF_SID:"",DEF_EVENT:"",DEF_META_STRING:"",DEF_DATA:new n.ByteBuffer(new ArrayBuffer(0)),CLOSE1000_PROTOCOL_CLOSE_STARTING:1e3,CLOSE1001_PROTOCOL_CLOSE:1001,CLOSE1002_PROTOCOL_ILLEGAL:1002,CLOSE2001_ERROR:2001,CLOSE2002_RECONNECT:2002,CLOSE2008_OPEN_FAIL:2008,CLOSE2009_USER:2009,MAX_SIZE_SID:64,MAX_SIZE_EVENT:512,MAX_SIZE_META_STRING:4096,MAX_SIZE_DATA:16777216,MAX_SIZE_FRAME:17825792,MIN_FRAGMENT_SIZE:1024,DEMANDS_ZERO:0,DEMANDS_SIGNLE:1,DEMANDS_MULTIPLE:2},t.Flags={Unknown:0,Connect:10,Connack:11,Ping:20,Pong:21,Close:30,Alarm:31,Message:40,Request:41,Subscribe:42,Reply:48,ReplyEnd:49,of:function(e){switch(e){case 10:return this.Connect;case 11:return this.Connack;case 20:return this.Ping;case 21:return this.Pong;case 30:return this.Close;case 31:return this.Alarm;case 40:return this.Message;case 41:return this.Request;case 42:return this.Subscribe;case 48:return this.Reply;case 49:return this.ReplyEnd;default:return this.Unknown}},name:function(e){switch(e){case this.Connect:return"Connect";case this.Connack:return"Connack";case this.Ping:return"Ping";case this.Pong:return"Pong";case this.Close:return"Close";case this.Alarm:return"Alarm";case this.Message:return"Message";case this.Request:return"Request";case this.Subscribe:return"Subscribe";case this.Reply:return"Reply";case this.ReplyEnd:return"ReplyEnd";default:return"Unknown"}}},t.EntityMetas={META_SOCKETD_VERSION:"Socket.D",META_DATA_LENGTH:"Data-Length",META_DATA_TYPE:"Data-Type",META_DATA_FRAGMENT_IDX:"Data-Fragment-Idx",META_DATA_FRAGMENT_TOTAL:"Data-Fragment-Total",META_DATA_DISPOSITION_FILENAME:"Data-Disposition-Filename",META_RANGE_START:"Data-Range-Start",META_RANGE_SIZE:"Data-Range-Size"}},8416:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FileEntity=t.StringEntity=t.EntityDefault=void 0;const n=s(9762),r=s(3321),i=s(7285),a=s(9612),o=s(7173);class l{constructor(){this._metaMap=null,this._data=i.Constants.DEF_DATA,this._dataAsReader=null}at(e){return this.metaPut("@",e),this}range(e,t){return this.metaPut(i.EntityMetas.META_RANGE_START,e.toString()),this.metaPut(i.EntityMetas.META_RANGE_SIZE,t.toString()),this}metaStringSet(e){if(this._metaMap=new Map,e)for(const t of e.split("&")){const e=t.indexOf("=");e>0&&this._metaMap.set(t.substring(0,e),t.substring(e+1))}return this}metaMapPut(e){if(e)if(e instanceof Map)e.forEach(((e,t,s)=>{this.metaMap().set(t,e)}));else for(const t of e.prototype)this.metaMap().set(t,e[t]);return this}metaPut(e,t){return null==t?this.metaMap().delete(e):this.metaMap().set(e,t),this}metaDel(e){this.metaMap().delete(e)}metaString(){let e="";return this.metaMap().forEach(((t,s,n)=>{e+=`${s}=${t}&`})),e.length>0?e.substring(0,e.length-1):e}metaMap(){return null==this._metaMap&&(this._metaMap=new Map),this._metaMap}meta(e){return this.metaMap().get(e)||null}metaOrDefault(e,t){return this.meta(e)||t}metaAsInt(e){return parseInt(this.metaOrDefault(e,"0"))}metaAsFloat(e){return parseFloat(this.metaOrDefault(e,"0"))}putMeta(e,t){this.metaPut(e,t)}delMeta(e){this.metaDel(e)}dataSet(e){return e instanceof ArrayBuffer?this._data=new a.ByteBuffer(e):this._data=new a.BlobBuffer(e),this}data(){return this._data}dataAsReader(){if(null==this._data.getArray())throw new o.SocketDException("Blob does not support dataAsReader");return this._dataAsReader||(this._dataAsReader=new r.ArrayBufferCodecReader(this._data.getArray())),this._dataAsReader}dataAsString(){if(null==this._data.getArray())throw new o.SocketDException("Blob does not support dataAsString");return n.StrUtils.bufToStrDo(this._data.getArray(),"")}dataSize(){return this._data.size()}release(){}toString(){return"Entity{meta='"+this.metaString()+"', data=byte["+this.dataSize()+"]}"}}t.EntityDefault=l,t.StringEntity=class extends l{constructor(e){super();const t=n.StrUtils.strToBuf(e);this.dataSet(t)}},t.FileEntity=class extends l{constructor(e){super(),this.dataSet(e),this.metaPut(i.EntityMetas.META_DATA_DISPOSITION_FILENAME,e.name)}}},9630:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentAggregatorDefault=void 0;const n=s(3558),r=s(8416),i=s(4419),a=s(9976),o=s(7285),l=s(7173);t.FragmentAggregatorDefault=class{constructor(e){this._fragmentHolders=new Array,this._dataStreamSize=0,this._dataLength=0,this._main=e;const t=e.meta(o.EntityMetas.META_DATA_LENGTH);if(!t)throw new l.SocketDCodecException("Missing '"+o.EntityMetas.META_DATA_LENGTH+"' meta, event="+e.event());this._dataLength=parseInt(t)}getSid(){return this._main.sid()}getDataStreamSize(){return this._dataStreamSize}getDataLength(){return this._dataLength}add(e,t){this._fragmentHolders.push(new a.FragmentHolder(e,t)),this._dataStreamSize=this._dataStreamSize+t.dataSize()}get(){this._fragmentHolders.sort(((e,t)=>e.getIndex()==t.getIndex()?0:e.getIndex()>t.getIndex()?1:-1));const e=new ArrayBuffer(this._dataLength),t=new DataView(e);let s=0;for(const e of this._fragmentHolders){const n=new DataView(e.getMessage().data().getArray());for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentHandlerDefault=void 0;const n=s(8416),r=s(7285),i=s(9630);t.FragmentHandlerDefault=class{spliFragment(e,t,s,r){if(s.dataSize()>e.getConfig().getFragmentSize()){let n=0,i=Math.ceil(s.dataSize()/e.getConfig().getFragmentSize());this.spliFragmentDo(n,i,e,t,s,r)}else null==s.data().getBlob()?(r(s),null!=t&&t.onProgress(!0,1,1)):s.data().getBytes(e.getConfig().getFragmentSize(),(e=>{r((new n.EntityDefault).dataSet(e).metaMapPut(s.metaMap())),null!=t&&t.onProgress(!0,1,1)}))}spliFragmentDo(e,t,s,i,a,o){e++,a.data().getBytes(s.getConfig().getFragmentSize(),(l=>{const u=(new n.EntityDefault).dataSet(l);1==e&&u.metaMapPut(a.metaMap()),u.metaPut(r.EntityMetas.META_DATA_FRAGMENT_IDX,e.toString()),u.metaPut(r.EntityMetas.META_DATA_FRAGMENT_TOTAL,t.toString()),o(u),null!=i&&i.onProgress(!0,e,t),this.spliFragmentDo(e,t,s,i,a,o)}))}aggrFragment(e,t,s){let n=e.getAttachment(s.sid());return n||(n=new i.FragmentAggregatorDefault(s),e.putAttachment(n.getSid(),n)),n.add(t,s),n.getDataLength()>n.getDataStreamSize()?null:(e.putAttachment(s.sid(),null),n.get())}aggrEnable(){return!0}}},9976:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentHolder=void 0,t.FragmentHolder=class{constructor(e,t){this._index=e,this._message=t}getIndex(){return this._index}getMessage(){return this._message}}},4419:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Frames=t.Frame=void 0;const n=s(8416),r=s(7285),i=s(3558),a=s(3306);class o{constructor(e,t){this._flag=e,this._message=t}flag(){return this._flag}message(){return this._message}toString(){return"Frame{flag="+r.Flags.name(this._flag)+", message="+this._message+"}"}}t.Frame=o,t.Frames=class{static connectFrame(e,t,s){const l=new n.StringEntity(t);return l.metaMapPut(s),l.metaPut(r.EntityMetas.META_SOCKETD_VERSION,a.SocketD.protocolVersion()),new o(r.Flags.Connect,(new i.MessageBuilder).sid(e).event(t).entity(l).build())}static connackFrame(e){const t=new n.EntityDefault;return t.metaMapPut(e.getOutMetaMap()),t.metaPut(r.EntityMetas.META_SOCKETD_VERSION,a.SocketD.protocolVersion()),t.dataSet(e.getSource().data().getArray()),new o(r.Flags.Connack,(new i.MessageBuilder).sid(e.getSource().sid()).event(e.getSource().event()).entity(t).build())}static pingFrame(){return new o(r.Flags.Ping,null)}static pongFrame(){return new o(r.Flags.Pong,null)}static closeFrame(e){const t=new i.MessageBuilder;return t.entity(new n.StringEntity("").metaPut("code",e.toString())),new o(r.Flags.Close,t.build())}static alarmFrame(e,t){const s=new i.MessageBuilder;return null!=e?(s.sid(e.sid()),s.event(e.event()),s.entity(new n.StringEntity(t).metaStringSet(e.metaString()))):s.entity(new n.StringEntity(t)),new o(r.Flags.Alarm,s.build())}}},4867:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HandshakeDefault=void 0;const n=s(7285),r=s(9762);t.HandshakeDefault=class{constructor(e){let t=e.dataAsString();null!=t&&""!=t||(t=e.event()),this._source=e,this._url=t,this._version=e.meta(n.EntityMetas.META_SOCKETD_VERSION),this._outMetaMap=new Map,this._paramMap=new Map;let s=r.StrUtils.parseUri(t);this._path=s.path;const i=s.query;if(i)for(const e of i.split("&")){const t=e.indexOf("=");t>0&&this._paramMap.set(e.substring(0,t),e.substring(t+1))}e.metaMap().forEach(((e,t,s)=>{this._paramMap.set(t,e)}))}getSource(){return this._source}getOutMetaMap(){return this._outMetaMap}uri(){return this._url}path(){return this._path}version(){return this._version}param(e){return this._paramMap.get(e)||null}paramMap(){return this._paramMap}paramOrDefault(e,t){return this.param(e)||t}paramPut(e,t){this._paramMap.set(e,t)}outMeta(e,t){this._outMetaMap.set(e,t)}}},8780:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GuidGenerator=void 0;const n=s(9762);t.GuidGenerator=class{generate(){return n.StrUtils.guid()}}},8350:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PipelineListener=t.PathListener=t.EventListener=t.SimpleListener=void 0;const n=s(7218);t.SimpleListener=class{onOpen(e){}onMessage(e,t){}onClose(e){}onError(e,t){}};class r{constructor(e){this._eventRouteSelector=e||new n.RouteSelectorDefault}doOn(e,t){return this._eventRouteSelector.put(e,t),this}doOnOpen(e){return this._doOnOpen=e,this}doOnMessage(e){return this._doOnMessage=e,this}doOnClose(e){return this._doOnClose=e,this}doOnError(e){return this._doOnError=e,this}onOpen(e){this._doOnOpen&&this._doOnOpen(e)}onMessage(e,t){this._doOnMessage&&this._doOnMessage(e,t);const s=this._eventRouteSelector.select(t.event());s&&s(e,t)}onClose(e){this._doOnClose&&this._doOnClose(e)}onError(e,t){this._doOnError&&this._doOnError(e,t)}}t.EventListener=r,t.PathListener=class{constructor(e){this._pathRouteSelector=e||new n.RouteSelectorDefault}doOf(e,t){return this._pathRouteSelector.put(e,t),this}of(e){const t=new r;return this._pathRouteSelector.put(e,t),t}size(){return this._pathRouteSelector.size()}onOpen(e){const t=this._pathRouteSelector.select(e.path());null!=t&&t.onOpen(e)}onMessage(e,t){const s=this._pathRouteSelector.select(e.path());null!=s&&s.onMessage(e,t)}onClose(e){const t=this._pathRouteSelector.select(e.path());null!=t&&t.onClose(e)}onError(e,t){const s=this._pathRouteSelector.select(e.path());null!=s&&s.onError(e,t)}},t.PipelineListener=class{constructor(){this._deque=new Array}prev(e){return this._deque.unshift(e),this}next(e){return this._deque.push(e),this}size(){return this._deque.length}onOpen(e){for(const t of this._deque)t.onOpen(e)}onMessage(e,t){for(const s of this._deque)s.onMessage(e,t)}onClose(e){for(const t of this._deque)t.onClose(e)}onError(e,t){for(const s of this._deque)s.onError(e,t)}}},3558:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDefault=t.MessageBuilder=void 0;const n=s(7285);t.MessageBuilder=class{constructor(){this._flag=n.Flags.Unknown,this._sid=n.Constants.DEF_SID,this._event=n.Constants.DEF_EVENT,this._entity=null}flag(e){return this._flag=e,this}sid(e){return this._sid=e,this}event(e){return this._event=e,this}entity(e){return this._entity=e,this}build(){return new r(this._flag,this._sid,this._event,this._entity)}};class r{constructor(e,t,s,n){this._flag=e,this._sid=t,this._event=s,this._entity=n}atName(){return this.meta("@")}rangeStart(){return this.metaAsInt(n.EntityMetas.META_RANGE_START)}rangeSize(){return this.metaAsInt(n.EntityMetas.META_RANGE_SIZE)}flag(){return this._flag}isRequest(){return this._flag==n.Flags.Request}isSubscribe(){return this._flag==n.Flags.Subscribe}isEnd(){return this._flag==n.Flags.ReplyEnd}sid(){return this._sid}event(){return this._event}entity(){return this._entity}toString(){return"Message{sid='"+this._sid+"', event='"+this._event+"', entity="+this._entity+"}"}metaString(){return this._entity.metaString()}metaMap(){return this._entity.metaMap()}meta(e){return this._entity.meta(e)}metaOrDefault(e,t){return this._entity.metaOrDefault(e,t)}metaAsInt(e){return this._entity.metaAsInt(e)}metaAsFloat(e){return this._entity.metaAsFloat(e)}putMeta(e,t){this._entity.putMeta(e,t)}delMeta(e){this._entity.delMeta(e)}data(){return this._entity.data()}dataAsReader(){return this._entity.dataAsReader()}dataAsString(){return this._entity.dataAsString()}dataSize(){return this._entity.dataSize()}release(){this._entity&&this._entity.release()}}t.MessageDefault=r},6322:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessorDefault=void 0;const n=s(8350),r=s(7285),i=s(7173),a=s(4867);t.ProcessorDefault=class{constructor(){this._listener=new n.SimpleListener}setListener(e){null!=e&&(this._listener=e)}onReceive(e,t){if(e.getConfig().clientMode()||console.debug("S-REV:"+t),t.flag()==r.Flags.Connect)e.setHandshake(new a.HandshakeDefault(t.message())),e.onOpenFuture(((t,s)=>{if(t&&e.isValid())try{e.sendConnack()}catch(s){this.onError(e,s)}})),this.onOpen(e);else if(t.flag()==r.Flags.Connack)e.setHandshake(new a.HandshakeDefault(t.message())),this.onOpen(e);else{if(null==e.getHandshake()){if(e.close(r.Constants.CLOSE1001_PROTOCOL_CLOSE),t.flag()==r.Flags.Close)throw new i.SocketDConnectionException("Connection request was rejected");return void console.warn(`${e.getConfig().getRoleName()} channel handshake is null, sessionId=${e.getSession().sessionId()}`)}e.setLiveTimeAsNow();try{switch(t.flag()){case r.Flags.Ping:e.sendPong();break;case r.Flags.Pong:break;case r.Flags.Close:{let s=0;null!=t.message()&&(s=t.message().metaAsInt("code")),0==s&&(s=r.Constants.CLOSE1001_PROTOCOL_CLOSE),e.close(s),s>r.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING&&this.onCloseInternal(e);break}case r.Flags.Alarm:{const s=new i.SocketDAlarmException(t.message()),n=e.getConfig().getStreamManger().getStream(t.message().sid());null==n?this.onError(e,s):(e.getConfig().getStreamManger().removeStream(t.message().sid()),n.onError(s));break}case r.Flags.Message:case r.Flags.Request:case r.Flags.Subscribe:this.onReceiveDo(e,t,!1);break;case r.Flags.Reply:case r.Flags.ReplyEnd:this.onReceiveDo(e,t,!0);break;default:e.close(r.Constants.CLOSE1002_PROTOCOL_ILLEGAL),this.onCloseInternal(e)}}catch(t){this.onError(e,t)}}}onReceiveDo(e,t,s){let n=null,i=1,a=1;if(s&&(n=e.getStream(t.message().sid())),e.getConfig().getFragmentHandler().aggrEnable()){const s=t.message().meta(r.EntityMetas.META_DATA_FRAGMENT_IDX);if(s){i=parseInt(s);const o=e.getConfig().getFragmentHandler().aggrFragment(e,i,t.message());if(n&&(a=parseInt(t.message().metaOrDefault(r.EntityMetas.META_DATA_FRAGMENT_TOTAL,"1"))),null==o)return void(n&&n.onProgress(!1,i,a));t=o}}s?(n&&n.onProgress(!1,i,a),e.retrieve(t,n)):this.onMessage(e,t.message())}onOpen(e){try{this._listener.onOpen(e.getSession()),e.doOpenFuture(!0,null)}catch(t){console.warn(`${e.getConfig().getRoleName()} channel listener onOpen error`,t),e.doOpenFuture(!1,t)}}onMessage(e,t){try{this._listener.onMessage(e.getSession(),t)}catch(t){console.warn(`${e.getConfig().getRoleName()} channel listener onMessage error`,t),this.onError(e,t)}}onClose(e){0==e.isClosed()&&this.onCloseInternal(e)}onCloseInternal(e){this._listener.onClose(e.getSession())}onError(e,t){this._listener.onError(e.getSession(),t)}}},7218:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouteSelectorDefault=void 0,t.RouteSelectorDefault=class{constructor(){this._inner=new Map}select(e){return this._inner.get(e)}put(e,t){this._inner.set(e,t)}remove(e){this._inner.delete(e)}size(){return this._inner.size}}},8342:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionBase=void 0,t.SessionBase=class{constructor(e){this._channel=e,this._attrMap=null,this._sessionId=this.generateId()}sessionId(){return this._sessionId}liveTime(){return this._channel.getLiveTime()}name(){return this.param("@")||null}attrMap(){return null==this._attrMap&&(this._attrMap=new Map),this._attrMap}attrHas(e){return null!=this._attrMap&&this._attrMap.has(e)}attr(e){return null==this._attrMap?null:this._attrMap.get(e)}attrOrDefault(e,t){return this.attr(e)||t}attrPut(e,t){this.attrMap().set(e,t)}generateId(){return this._channel.getConfig().getIdGenerator().generate()}}},7082:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SessionDefault=void 0;const n=s(8342),r=s(8416),i=s(3558),a=s(4419),o=s(7285),l=s(5740);class u extends n.SessionBase{constructor(e){super(e)}isValid(){return this._channel.isValid()}isClosing(){return this._channel.isClosing()}remoteAddress(){return this._channel.getRemoteAddress()}localAddress(){return this._channel.getLocalAddress()}handshake(){return this._channel.getHandshake()}param(e){return this.handshake().param(e)}paramOrDefault(e,t){return this.handshake().paramOrDefault(e,t)}path(){return null==this._pathNew?this.handshake().path():this._pathNew}pathNew(e){this._pathNew=e}reconnect(){this._channel.reconnect()}sendPing(){this._channel.sendPing()}sendAlarm(e,t){this._channel.sendAlarm(e,t)}send(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build(),n=new l.SendStreamImpl(s.sid());return this._channel.send(new a.Frame(o.Flags.Message,s),n),n}sendAndRequest(e,t,s){null==t&&(t=new r.EntityDefault);const n=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build();s||(s=0),s<0&&(s=this._channel.getConfig().getStreamTimeout()),0==s&&(s=this._channel.getConfig().getRequestTimeout());const u=new l.RequestStreamImpl(n.sid(),s);return this._channel.send(new a.Frame(o.Flags.Request,n),u),u}sendAndSubscribe(e,t,s){null==t&&(t=new r.EntityDefault);const n=(new i.MessageBuilder).sid(this.generateId()).event(e).entity(t).build();s||(s=0),s<=0&&(s=this._channel.getConfig().getStreamTimeout());const u=new l.SubscribeStreamImpl(n.sid(),s);return this._channel.send(new a.Frame(o.Flags.Subscribe,n),u),u}reply(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(e.sid()).event(e.event()).entity(t).build();this._channel.send(new a.Frame(o.Flags.Reply,s),null)}replyEnd(e,t){null==t&&(t=new r.EntityDefault);const s=(new i.MessageBuilder).sid(e.sid()).event(e.event()).entity(t).build();this._channel.send(new a.Frame(o.Flags.ReplyEnd,s),null)}closeStarting(){console.debug(`${this._channel.getConfig().getRoleName()} session close starting, sessionId=${this.sessionId()}`),this._channel.isValid()&&this._channel.sendClose(o.Constants.CLOSE1000_PROTOCOL_CLOSE_STARTING)}close(){if(console.debug(`${this._channel.getConfig().getRoleName()} session will be closed, sessionId=${this.sessionId()}`),this._channel.isValid())try{this._channel.sendClose(o.Constants.CLOSE1001_PROTOCOL_CLOSE)}catch(e){console.warn(`${this._channel.getConfig().getRoleName()} channel sendClose error`,e)}this._channel.close(o.Constants.CLOSE2009_USER)}}t.SessionDefault=u},6719:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SocketAddress=void 0,t.SocketAddress=class{constructor(e,t,s){this.address=e,this.family=t,this.port=s}}},1151:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServerBase=void 0;const n=s(6322);t.ServerBase=class{constructor(e,t){this._processor=new n.ProcessorDefault,this._config=e,this._assistant=t}getAssistant(){return this._assistant}getConfig(){return this._config}config(e){return e&&e(this._config),this}getProcessor(){return this._processor}listen(e){return e&&this._processor.setListener(e),this}}},3863:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServerConfig=void 0;const n=s(7267);class r extends n.ConfigBase{constructor(e){super(!1),e.startsWith("sd:")&&(e=e.substring(3)),this._schema=e,this._host="",this._port=8602}getSchema(){return this._schema}getHost(){return this._host}getHttpServer(){return this._httpServer}httpServer(e){return this._httpServer=e,this}host(e){return this._host=e,this}getPort(){return this._port}port(e){return this._port=e,this}getLocalUrl(){return this._host?"sd:"+this._schema+"://"+this._host+":"+this._port:"sd:"+this._schema+"://127.0.0.1:"+this._port}toString(){return"ServerConfig{schema='"+this._schema+"', charset="+this._charset+", host='"+this._host+"', port="+this._port+", ioThreads="+this._ioThreads+", codecThreads="+this._codecThreads+", exchangeThreads="+this._exchangeThreads+", idleTimeout="+this._idleTimeout+", requestTimeout="+this._requestTimeout+", streamTimeout="+this._streamTimeout+", readBufferSize="+this._readBufferSize+", writeBufferSize="+this._writeBufferSize+", maxUdpSize="+this._maxUdpSize+"}"}}t.ServerConfig=r},5740:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StreamMangerDefault=t.SubscribeStreamImpl=t.RequestStreamImpl=t.SendStreamImpl=t.StreamBase=void 0;const n=s(7173),r=s(2805),i=s(7285);class a{constructor(e,t,s){this._sid=e,this._demands=t,this._timeout=s}sid(){return this._sid}demands(){return this._demands}timeout(){return this._timeout}insuranceStart(e,t){this._insuranceFuture||(this._insuranceFuture=setTimeout((()=>{e.removeStream(this.sid()),this.onError(new n.SocketDTimeoutException("The stream response timeout, sid="+this.sid()))}),t))}insuranceCancel(){this._insuranceFuture&&clearTimeout(this._insuranceFuture)}onError(e){this._doOnError&&this._doOnError(e)}onProgress(e,t,s){this._doOnProgress&&this._doOnProgress(e,t,s)}thenError(e){return this._doOnError=e,this}thenProgress(e){return this._doOnProgress=e,this}}t.StreamBase=a,t.SendStreamImpl=class extends a{constructor(e){super(e,i.Constants.DEMANDS_ZERO,0)}isDone(){return!0}onReply(e){}},t.RequestStreamImpl=class extends a{constructor(e,t){super(e,i.Constants.DEMANDS_SIGNLE,t),this._isDone=!1}isDone(){return this._isDone}onReply(e){this._isDone=!0;try{this._doOnReply&&this._doOnReply(e)}catch(e){this.onError(e)}}await(){return new Promise(((e,t)=>{this.thenReply((t=>{e(t)})).thenError((e=>{t(e)}))}))}thenReply(e){return this._doOnReply=e,this}},t.SubscribeStreamImpl=class extends a{constructor(e,t){super(e,i.Constants.DEMANDS_MULTIPLE,t),this._isDone=!1}isDone(){return this._isDone}onReply(e){this._isDone=e.isEnd();try{this._doOnReply&&this._doOnReply(e)}catch(e){this.onError(e)}}thenReply(e){return this._doOnReply=e,this}},t.StreamMangerDefault=class{constructor(e){this._config=e,this._streamMap=new Map}getStream(e){return this._streamMap.get(e)||null}addStream(e,t){if(r.Asserts.assertNull("stream",t),t.demands()==i.Constants.DEMANDS_ZERO)return;this._streamMap.set(e,t);const s=t.timeout()>0?t.timeout():this._config.getStreamTimeout();s>0&&t.insuranceStart(this,s)}removeStream(e){const t=this.getStream(e);t&&(this._streamMap.delete(e),t.insuranceCancel(),console.debug(`${this._config.getRoleName()} stream removed, sid=${e}`))}}},7472:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsChannelAssistant=void 0;const n=s(3321);t.WsChannelAssistant=class{constructor(e){this._config=e}read(e){return this._config.getCodec().read(new n.ArrayBufferCodecReader(e))}write(e,t){let s=this._config.getCodec().write(t,(e=>new n.ArrayBufferCodecWriter(e)));e.send(s.getBuffer())}isValid(e){return e.isOpen()}close(e){e.close()}getRemoteAddress(e){return e.remoteAddress()}getLocalAddress(e){return e.localAddress()}}},2960:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsClient=void 0;const n=s(7788),r=s(7472),i=s(7738);class a extends n.ClientBase{constructor(e){super(e,new r.WsChannelAssistant(e))}createConnector(){return new i.WsClientConnector(this)}}t.WsClient=a},7738:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClientImpl=t.WsClientConnector=void 0;const n=s(1479),r=s(7321),i=s(1900),a=s(4851),o=s(7285),l=s(7173);class u extends n.ClientConnectorBase{constructor(e){super(e)}connect(){this.close();let e=this._client.getConfig().getUrl();return new Promise(((t,s)=>{try{this._real=new c(e,this._client,(e=>{e.getThrowable()?s(e.getThrowable()):t(e.getChannel())}))}catch(e){s(e)}}))}close(){this._real&&this._real.close()}}t.WsClientConnector=u;class c{constructor(e,t,s){try{this._real=i.EnvBridge.createSdWebSocketClient(e,this)}catch(e){s(new r.ClientHandshakeResult(null,e))}this._client=t,this._channel=new a.ChannelDefault(this._real,t),this._handshakeFuture=s}onOpen(e){try{this._channel.sendConnect(this._client.getConfig().getUrl(),this._client.getConfig().getMetaMap())}catch(e){console.warn("Client channel sendConnect error",e)}}onMessage(e){if(e.data()instanceof String)console.warn("Client channel unsupported onMessage(String test)");else try{let t=this._client.getAssistant().read(e.data());null!=t&&(t.flag()==o.Flags.Connack&&this._channel.onOpenFuture(((e,t)=>{this.handshakeFutureDo(t)})),this._client.getProcessor().onReceive(this._channel,t))}catch(e){e instanceof l.SocketDConnectionException&&this.handshakeFutureDo(e),console.warn("WebSocket client onMessage error",e)}}onClose(e){this._client.getProcessor().onClose(this._channel)}onError(e){this.handshakeFutureDo(e.error()),this._client.getProcessor().onError(this._channel,e.error())}handshakeFutureDo(e){this._handshakeFuture?this._handshakeFuture(new r.ClientHandshakeResult(this._channel,e)):this._handshakeFuture=null}close(){this._real.close()}}t.WebSocketClientImpl=c},4294:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WsProvider=void 0;const n=s(2960),r=s(6607);t.WsProvider=class{schemas(){return["ws","wss","sd:ws","sd:wss"]}createClient(e){return new n.WsClient(e)}createServer(e){return new r.WsServer(e)}}},6607:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketServerListener=t.WsServer=void 0;const r=s(1151),i=s(7472),a=s(3306),o=n(s(7026)),l=s(1163),u=s(7285);class c extends r.ServerBase{constructor(e){super(e,new i.WsChannelAssistant(e))}getTitle(){return"ws/js-websocket/v"+a.SocketD.version()}start(){if(this._isStarted)throw new Error("Socket.D server started");this._isStarted=!0,this.getConfig().getHttpServer()?this._server=new o.default.Server({server:this.getConfig().getHttpServer(),maxPayload:u.Constants.MAX_SIZE_FRAME}):this.getConfig().getHost()?this._server=new o.default.Server({port:this.getConfig().getPort(),host:this.getConfig().getHost(),maxPayload:u.Constants.MAX_SIZE_FRAME}):this._server=new o.default.Server({port:this.getConfig().getPort(),maxPayload:u.Constants.MAX_SIZE_FRAME});const e=new h(this);return this._server.on("connection",((t,s)=>{new l.SdWebSocketNodeJs(t,s,e)})),console.info("Socket.D server started: {server="+this.getConfig().getLocalUrl()+"}"),this}stop(){if(this._isStarted){this._isStarted=!1;try{null!=this._server&&this._server.close()}catch(e){console.debug("Server stop error",e)}}}}t.WsServer=c;class h{constructor(e){this._server=e}getServer(){return this._server}onOpen(e){let t=e.socket().attachment();this._server.getProcessor().onClose(t)}onMessage(e){let t=e.socket().attachment(),s=this._server.getAssistant().read(e.data());null!=s&&this._server.getProcessor().onReceive(t,s)}onClose(e){let t=e.socket().attachment();this._server.getProcessor().onClose(t)}onError(e){let t=e.socket().attachment();t&&this._server.getProcessor().onError(t,e.error())}}t.SdWebSocketServerListener=h},1900:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvBridge=t.Runtime=void 0;const n=s(1243),r=s(1095),i=s(8148),a=s(9739);var o;!function(e){e[e.Unknown=0]="Unknown",e[e.Browser=1]="Browser",e[e.NodeJs=2]="NodeJs",e[e.Uniapp=3]="Uniapp",e[e.Weixin=4]="Weixin"}(o||(t.Runtime=o={})),t.EnvBridge=class{static getRuntime(){return"undefined"!=typeof window?"undefined"!=typeof uni&&uni.connectSocket?o.Uniapp:"undefined"!=typeof wx&&wx.connectSocket&&wx.request?o.Weixin:o.Browser:"undefined"!=typeof process&&process.versions&&process.versions.node?o.NodeJs:"undefined"!=typeof uni&&uni.connectSocket?o.Uniapp:o.Unknown}static createSdWebSocketClient(e,t){let s=this.getRuntime();return s==o.Weixin?(console.info("Client channel use xeixin api!"),new a.SdWebSocketWeixinClient(e,t)):s==o.Uniapp?(console.info("Client channel use uniapp api!"),new i.SdWebSocketUniappClient(e,t)):s==o.NodeJs?(console.info("Client channel use nodejs api"),new r.SdWebSocketNodeJsClient(e,t)):(console.info("Client channel use browser api"),new n.SdWebSocketBrowserClient(e,t))}}},8887:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketErrorEventImpl=t.SdWebSocketCloseEventImpl=t.SdWebSocketMessageEventImpl=t.SdWebSocketEventImpl=t.SdWebSocketState=void 0,function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(s||(t.SdWebSocketState=s={})),t.SdWebSocketEventImpl=class{constructor(e){this._socket=e}socket(){return this._socket}},t.SdWebSocketMessageEventImpl=class{constructor(e,t){this._socket=e,this._data=t}socket(){return this._socket}data(){return this._data}},t.SdWebSocketCloseEventImpl=class{constructor(e){this._socket=e}socket(){return this._socket}},t.SdWebSocketErrorEventImpl=class{constructor(e,t){this._socket=e,this._error=t}socket(){return this._socket}error(){return this._error}}},1243:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketBrowserClient=void 0;const n=s(8887);t.SdWebSocketBrowserClient=class{constructor(e,t){this._real=new WebSocket(e),this._listener=t,this._real.binaryType="arraybuffer",this._real.onopen=this.onOpen.bind(this),this._real.onmessage=this.onMessage.bind(this),this._real.onclose=this.onClose.bind(this),this._real.onerror=this.onError.bind(this)}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._real.readyState==WebSocket.CONNECTING}isClosed(){return this._real.readyState==WebSocket.CLOSED}isClosing(){return this._real.readyState==WebSocket.CLOSING}isOpen(){return this._real.readyState==WebSocket.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},1163:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketNodeJs=void 0;const r=s(8887),i=n(s(7026)),a=s(6719),o=s(4851);t.SdWebSocketNodeJs=class{constructor(e,t,s){this._real=e,this._listener=s,this._real.binaryType="arraybuffer",t.socket.remoteAddress?this._remoteAddress=new a.SocketAddress(t.socket.remoteAddress,t.socket.remoteFamily,t.socket.remotePort):this._remoteAddress=null,t.socket.localAddress?this._localAddress=new a.SocketAddress(t.socket.localAddress,t.socket.localFamily,t.socket.localPort):this._localAddress=null;const n=new o.ChannelDefault(this,s.getServer());this.attachmentPut(n),this._real.on("open",this.onOpen.bind(this)),this._real.on("message",this.onMessage.bind(this)),this._real.on("close",this.onClose.bind(this)),this._real.on("error",this.onError.bind(this))}remoteAddress(){return this._remoteAddress}localAddress(){return this._localAddress}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isClosed(){return this._real.readyState==i.default.CLOSED}isClosing(){return this._real.readyState==i.default.CLOSING}isConnecting(){return this._real.readyState==i.default.CONNECTING}isOpen(){return this._real.readyState==i.default.OPEN}onOpen(){let e=new r.SdWebSocketEventImpl(this);this._listener.onOpen(e)}onMessage(e){let t=new r.SdWebSocketMessageEventImpl(this,e);this._listener.onMessage(t)}onClose(){let e=new r.SdWebSocketCloseEventImpl(this);this._listener.onClose(e)}onError(e){let t=new r.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},1095:function(e,t,s){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketNodeJsClient=void 0;const r=s(8887),i=n(s(7026));t.SdWebSocketNodeJsClient=class{constructor(e,t){this._real=new i.default(e),this._listener=t,this._real.binaryType="arraybuffer",this._real.on("open",this.onOpen.bind(this)),this._real.on("message",this.onMessage.bind(this)),this._real.on("close",this.onClose.bind(this)),this._real.on("error",this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isClosed(){return this._real.readyState==i.default.CLOSED}isClosing(){return this._real.readyState==i.default.CLOSING}isConnecting(){return this._real.readyState==i.default.CONNECTING}isOpen(){return this._real.readyState==i.default.OPEN}onOpen(){let e=new r.SdWebSocketEventImpl(this);this._listener.onOpen(e)}onMessage(e){let t=new r.SdWebSocketMessageEventImpl(this,e);this._listener.onMessage(t)}onClose(){let e=new r.SdWebSocketCloseEventImpl(this);this._listener.onClose(e)}onError(e){let t=new r.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._real.close()}send(e){this._real.send(e)}}},8148:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketUniappClient=void 0;const n=s(8887);t.SdWebSocketUniappClient=class{constructor(e,t){this._state=n.SdWebSocketState.CONNECTING,this._real=uni.connectSocket({url:e,success:e=>{}}),this._listener=t,this._real.onOpen(this.onOpen.bind(this)),this._real.onMessage(this.onMessage.bind(this)),this._real.onClose(this.onClose.bind(this)),this._real.onError(this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._state==n.SdWebSocketState.CONNECTING}isClosed(){return this._state==n.SdWebSocketState.CLOSED}isClosing(){return this._state==n.SdWebSocketState.CLOSING}isOpen(){return this._state==n.SdWebSocketState.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._state=n.SdWebSocketState.OPEN,this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._state=n.SdWebSocketState.CLOSED,this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._state=n.SdWebSocketState.CLOSING,this._real.close({complete:()=>{this._state=n.SdWebSocketState.CLOSED}})}send(e){this._real.send({data:e})}}},9739:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SdWebSocketWeixinClient=void 0;const n=s(8887);t.SdWebSocketWeixinClient=class{constructor(e,t){this._state=n.SdWebSocketState.CONNECTING,this._real=wx.connectSocket({url:e}),this._listener=t,this._real.binaryType="arraybuffer",this._real.onOpen(this.onOpen.bind(this)),this._real.onMessage(this.onMessage.bind(this)),this._real.onClose(this.onClose.bind(this)),this._real.onError(this.onError.bind(this))}remoteAddress(){return null}localAddress(){return null}attachment(){return this._attachment}attachmentPut(e){this._attachment=e}isConnecting(){return this._state==n.SdWebSocketState.CONNECTING}isClosed(){return this._state==n.SdWebSocketState.CLOSED}isClosing(){return this._state==n.SdWebSocketState.CLOSING}isOpen(){return this._state==n.SdWebSocketState.OPEN}onOpen(e){let t=new n.SdWebSocketEventImpl(this);this._state=n.SdWebSocketState.OPEN,this._listener.onOpen(t)}onMessage(e){let t=new n.SdWebSocketMessageEventImpl(this,e.data);this._listener.onMessage(t)}onClose(e){let t=new n.SdWebSocketCloseEventImpl(this);this._state=n.SdWebSocketState.CLOSED,this._listener.onClose(t)}onError(e){let t=new n.SdWebSocketErrorEventImpl(this,e);this._listener.onError(t)}close(){this._state=n.SdWebSocketState.CLOSING,this._real.close({complete:()=>{this._state=n.SdWebSocketState.CLOSED}})}send(e){this._real.send({data:e})}}},2974:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RunUtils=void 0,t.RunUtils=class{static runAndTry(e){try{e()}catch(e){}}}},9762:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StrUtils=void 0;class s{static guid(){let e="";for(let t=1;t<=32;t++)e+=Math.floor(16*Math.random()).toString(16);return e}static parseUri(e){if(!e)return"";let t=e.indexOf("?");if(t){let n=e.substring(0,t),r=e.substring(t,e.length),i=s.parseUriDo(n);return i.source=e,i.query=r.substring(1,r.length),i.relative=r,i}return s.parseUriDo(e)}static parseUriDo(e){if(!e)return"";let t=s.parseUriOptions,n=t.parser[t.strictMode?"strict":"loose"].exec(e),r={},i=14;for(;i--;)r[t.key[i]]=n[i]||"";return r[t.q.name]={},r[t.key[12]].replace(t.q.parser,(function(e,s,n){s&&(r[t.q.name][s]=n)})),r}static strToBuf(e,t){return t||(t="utf-8"),(new TextEncoder).encode(e).buffer}static bufToStr(e,t,n,r){if(e.byteLength!=n){const s=new DataView(e),r=new ArrayBuffer(n),i=new DataView(r);for(let e=0;e{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}},t={},s=function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,s),i.exports}(1625),n=window;for(var r in s)n[r]=s[r];s.__esModule&&Object.defineProperty(n,"__esModule",{value:!0}); \ No newline at end of file