@litert/televoke 0.4.7 → 1.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +4 -2
- package/README.md +13 -8
- package/lib/client/Client.decl.d.ts +47 -0
- package/lib/client/Client.decl.d.ts.map +1 -0
- package/lib/client/Client.decl.js +18 -0
- package/lib/client/Client.decl.js.map +1 -0
- package/lib/client/JsonApiClient.impl.d.ts +28 -0
- package/lib/client/JsonApiClient.impl.d.ts.map +1 -0
- package/lib/client/JsonApiClient.impl.js +169 -0
- package/lib/client/JsonApiClient.impl.js.map +1 -0
- package/lib/client/LegacyHttpClient.impl.d.ts +62 -0
- package/lib/client/LegacyHttpClient.impl.d.ts.map +1 -0
- package/lib/client/LegacyHttpClient.impl.js +163 -0
- package/lib/client/LegacyHttpClient.impl.js.map +1 -0
- package/lib/client/index.d.ts +19 -0
- package/lib/client/index.d.ts.map +1 -0
- package/lib/client/index.js +35 -0
- package/lib/client/index.js.map +1 -0
- package/lib/index.d.ts +18 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -20
- package/lib/index.js.map +1 -1
- package/lib/server/LegacyServerChannel.impl.d.ts +38 -0
- package/lib/server/LegacyServerChannel.impl.d.ts.map +1 -0
- package/lib/server/LegacyServerChannel.impl.js +51 -0
- package/lib/server/LegacyServerChannel.impl.js.map +1 -0
- package/lib/server/Server.decl.d.ts +81 -0
- package/lib/server/Server.decl.d.ts.map +1 -0
- package/lib/server/Server.decl.js +18 -0
- package/lib/server/Server.decl.js.map +1 -0
- package/lib/server/Server.impl.d.ts +33 -0
- package/lib/server/Server.impl.d.ts.map +1 -0
- package/lib/server/Server.impl.js +58 -0
- package/lib/server/Server.impl.js.map +1 -0
- package/lib/server/ServerChannel.d.ts +20 -0
- package/lib/server/ServerChannel.d.ts.map +1 -0
- package/lib/server/ServerChannel.js +23 -0
- package/lib/server/ServerChannel.js.map +1 -0
- package/lib/server/SimpleJsonApiRouter.d.ts +28 -0
- package/lib/server/SimpleJsonApiRouter.d.ts.map +1 -0
- package/lib/server/SimpleJsonApiRouter.js +92 -0
- package/lib/server/SimpleJsonApiRouter.js.map +1 -0
- package/lib/server/index.d.ts +19 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +35 -0
- package/lib/server/index.js.map +1 -0
- package/lib/shared/BinaryStream.d.ts +36 -0
- package/lib/shared/BinaryStream.d.ts.map +1 -0
- package/lib/shared/BinaryStream.js +100 -0
- package/lib/shared/BinaryStream.js.map +1 -0
- package/lib/shared/BinaryStreamManager.d.ts +52 -0
- package/lib/shared/BinaryStreamManager.d.ts.map +1 -0
- package/lib/shared/BinaryStreamManager.js +105 -0
- package/lib/shared/BinaryStreamManager.js.map +1 -0
- package/lib/shared/Channel.impl.d.ts +79 -0
- package/lib/shared/Channel.impl.d.ts.map +1 -0
- package/lib/shared/Channel.impl.js +448 -0
- package/lib/shared/Channel.impl.js.map +1 -0
- package/lib/shared/Constants.d.ts +32 -0
- package/lib/shared/Constants.d.ts.map +1 -0
- package/lib/shared/Constants.js +35 -0
- package/lib/shared/Constants.js.map +1 -0
- package/lib/shared/Encodings/index.d.ts +18 -0
- package/lib/shared/Encodings/index.d.ts.map +1 -0
- package/lib/shared/Encodings/index.js +21 -0
- package/lib/shared/Encodings/index.js.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts +22 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.js +47 -0
- package/lib/shared/Encodings/v1/EncoderV1.js.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts +78 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js +53 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js.map +1 -0
- package/lib/shared/Encodings/v1/index.d.ts +18 -0
- package/lib/shared/Encodings/v1/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/index.js +34 -0
- package/lib/shared/Encodings/v1/index.js.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts +29 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.js +34 -0
- package/lib/shared/Encodings/v2/Constants.v2.js.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts +27 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.js +281 -0
- package/lib/shared/Encodings/v2/DecoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts +21 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.js +177 -0
- package/lib/shared/Encodings/v2/EncoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts +99 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js +18 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js.map +1 -0
- package/lib/shared/Encodings/v2/index.d.ts +20 -0
- package/lib/shared/Encodings/v2/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/index.js +35 -0
- package/lib/shared/Encodings/v2/index.js.map +1 -0
- package/lib/shared/Errors.d.ts +61 -0
- package/lib/shared/Errors.d.ts.map +1 -0
- package/lib/shared/Errors.js +76 -0
- package/lib/shared/Errors.js.map +1 -0
- package/lib/shared/Shared.decl.d.ts +313 -0
- package/lib/shared/Shared.decl.d.ts.map +1 -0
- package/lib/shared/Shared.decl.js +18 -0
- package/lib/shared/Shared.decl.js.map +1 -0
- package/lib/shared/Utils.d.ts +25 -0
- package/lib/shared/Utils.d.ts.map +1 -0
- package/lib/shared/Utils.js +46 -0
- package/lib/shared/Utils.js.map +1 -0
- package/lib/shared/index.d.ts +23 -0
- package/lib/shared/index.d.ts.map +1 -0
- package/lib/shared/index.js +39 -0
- package/lib/shared/index.js.map +1 -0
- package/lib/transporters/Transporter.decl.d.ts +90 -0
- package/lib/transporters/Transporter.decl.d.ts.map +1 -0
- package/lib/transporters/Transporter.decl.js +18 -0
- package/lib/transporters/Transporter.decl.js.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts +32 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js +46 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts +95 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.js +52 -0
- package/lib/transporters/http-listener/Http.Decl.js.map +1 -0
- package/lib/transporters/http-listener/HttpListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpListener.js +73 -0
- package/lib/transporters/http-listener/HttpListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js +72 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.js +73 -0
- package/lib/transporters/http-listener/HttpsListener.js.map +1 -0
- package/lib/transporters/http-listener/index.d.ts +20 -0
- package/lib/transporters/http-listener/index.d.ts.map +1 -0
- package/lib/transporters/http-listener/index.js +36 -0
- package/lib/transporters/http-listener/index.js.map +1 -0
- package/lib/transporters/index.d.ts +17 -0
- package/lib/transporters/index.d.ts.map +1 -0
- package/lib/transporters/index.js +18 -0
- package/lib/transporters/index.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts +24 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js +167 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts +28 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js +55 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js.map +1 -0
- package/lib/transporters/legacy-http/index.d.ts +18 -0
- package/lib/transporters/legacy-http/index.d.ts.map +1 -0
- package/lib/transporters/legacy-http/index.js +34 -0
- package/lib/transporters/legacy-http/index.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts +34 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js +78 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js.map +1 -0
- package/lib/transporters/lwdfx/index.d.ts +23 -0
- package/lib/transporters/lwdfx/index.d.ts.map +1 -0
- package/lib/transporters/lwdfx/index.js +39 -0
- package/lib/transporters/lwdfx/index.js.map +1 -0
- package/lib/transporters/memory/Memory.Impl.d.ts +43 -0
- package/lib/transporters/memory/Memory.Impl.d.ts.map +1 -0
- package/lib/transporters/memory/Memory.Impl.js +227 -0
- package/lib/transporters/memory/Memory.Impl.js.map +1 -0
- package/lib/transporters/memory/index.d.ts +17 -0
- package/lib/transporters/memory/index.d.ts.map +1 -0
- package/lib/transporters/memory/index.js +33 -0
- package/lib/transporters/memory/index.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts +20 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.js +68 -0
- package/lib/transporters/websocket/WebSocket.Client.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts +25 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.js +87 -0
- package/lib/transporters/websocket/WebSocket.Server.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts +34 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js +106 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts +19 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.js +22 -0
- package/lib/transporters/websocket/WebSocket.decl.js.map +1 -0
- package/lib/transporters/websocket/index.d.ts +19 -0
- package/lib/transporters/websocket/index.d.ts.map +1 -0
- package/lib/transporters/websocket/index.js +35 -0
- package/lib/transporters/websocket/index.js.map +1 -0
- package/package.json +12 -12
- package/src/lib/client/Client.decl.ts +61 -0
- package/src/lib/client/JsonApiClient.impl.ts +258 -0
- package/src/lib/client/LegacyHttpClient.impl.ts +278 -0
- package/src/lib/client/index.ts +19 -0
- package/src/lib/index.ts +18 -20
- package/src/lib/server/LegacyServerChannel.impl.ts +71 -0
- package/src/lib/server/Server.decl.ts +109 -0
- package/src/lib/server/Server.impl.ts +90 -0
- package/src/lib/server/ServerChannel.ts +20 -0
- package/src/lib/server/SimpleJsonApiRouter.ts +135 -0
- package/src/lib/server/index.ts +19 -0
- package/src/lib/shared/BinaryStream.ts +141 -0
- package/src/lib/shared/BinaryStreamManager.ts +142 -0
- package/src/lib/shared/Channel.impl.ts +658 -0
- package/src/lib/shared/Constants.ts +35 -0
- package/src/lib/shared/Encodings/index.ts +18 -0
- package/src/lib/shared/Encodings/v1/EncoderV1.ts +66 -0
- package/src/lib/shared/Encodings/v1/Protocol.v1.decls.ts +96 -0
- package/src/lib/shared/Encodings/v1/index.ts +18 -0
- package/src/lib/shared/Encodings/v2/Constants.v2.ts +31 -0
- package/src/lib/shared/Encodings/v2/DecoderV2.ts +406 -0
- package/src/lib/shared/Encodings/v2/EncoderV2.ts +284 -0
- package/src/lib/shared/Encodings/v2/Encoding.v2.decl.ts +138 -0
- package/src/lib/shared/Encodings/v2/index.ts +20 -0
- package/src/lib/shared/Errors.ts +95 -0
- package/src/lib/shared/Shared.decl.ts +366 -0
- package/src/lib/shared/Utils.ts +51 -0
- package/src/lib/shared/index.ts +23 -0
- package/src/lib/transporters/Transporter.decl.ts +117 -0
- package/src/lib/transporters/http-listener/AbstractHttpListener.ts +57 -0
- package/src/lib/transporters/http-listener/Http.Decl.ts +141 -0
- package/src/lib/transporters/http-listener/HttpListener.ts +102 -0
- package/src/lib/transporters/http-listener/HttpUnixSocketListener.ts +97 -0
- package/src/lib/transporters/http-listener/HttpsListener.ts +102 -0
- package/src/lib/transporters/http-listener/index.ts +20 -0
- package/src/lib/transporters/index.ts +17 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Server.ts +262 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Transporter.ts +66 -0
- package/src/lib/transporters/legacy-http/index.ts +18 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Transporter.ts +100 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.decl.ts +19 -0
- package/src/lib/transporters/lwdfx/index.ts +23 -0
- package/src/lib/transporters/memory/Memory.Impl.ts +363 -0
- package/src/lib/transporters/memory/index.ts +17 -0
- package/src/lib/transporters/websocket/WebSocket.Client.ts +76 -0
- package/src/lib/transporters/websocket/WebSocket.Server.ts +118 -0
- package/src/lib/transporters/websocket/WebSocket.Transporter.ts +132 -0
- package/src/lib/transporters/websocket/WebSocket.decl.ts +21 -0
- package/src/lib/transporters/websocket/index.ts +19 -0
- package/lib/Client/BuiltInRIDGenerator.d.ts +0 -4
- package/lib/Client/BuiltInRIDGenerator.d.ts.map +0 -1
- package/lib/Client/BuiltInRIDGenerator.js +0 -18
- package/lib/Client/BuiltInRIDGenerator.js.map +0 -1
- package/lib/Client/Common.d.ts +0 -47
- package/lib/Client/Common.d.ts.map +0 -1
- package/lib/Client/Common.js +0 -18
- package/lib/Client/Common.js.map +0 -1
- package/lib/Client/Errors.d.ts +0 -26
- package/lib/Client/Errors.d.ts.map +0 -1
- package/lib/Client/Errors.js +0 -80
- package/lib/Client/Errors.js.map +0 -1
- package/lib/Client/HttpClient.d.ts +0 -37
- package/lib/Client/HttpClient.d.ts.map +0 -1
- package/lib/Client/HttpClient.js +0 -148
- package/lib/Client/HttpClient.js.map +0 -1
- package/lib/Client/HttpsClient.d.ts +0 -40
- package/lib/Client/HttpsClient.d.ts.map +0 -1
- package/lib/Client/HttpsClient.js +0 -144
- package/lib/Client/HttpsClient.js.map +0 -1
- package/lib/Client/TCPClient.d.ts +0 -34
- package/lib/Client/TCPClient.d.ts.map +0 -1
- package/lib/Client/TCPClient.js +0 -271
- package/lib/Client/TCPClient.js.map +0 -1
- package/lib/Client/TLSClient.d.ts +0 -34
- package/lib/Client/TLSClient.d.ts.map +0 -1
- package/lib/Client/TLSClient.js +0 -265
- package/lib/Client/TLSClient.js.map +0 -1
- package/lib/Client/index.d.ts +0 -23
- package/lib/Client/index.d.ts.map +0 -1
- package/lib/Client/index.js +0 -39
- package/lib/Client/index.js.map +0 -1
- package/lib/Common/API.d.ts +0 -19
- package/lib/Common/API.d.ts.map +0 -1
- package/lib/Common/API.js +0 -18
- package/lib/Common/API.js.map +0 -1
- package/lib/Common/Encoding.d.ts +0 -32
- package/lib/Common/Encoding.d.ts.map +0 -1
- package/lib/Common/Encoding.js +0 -20
- package/lib/Common/Encoding.js.map +0 -1
- package/lib/Common/Request.d.ts +0 -23
- package/lib/Common/Request.d.ts.map +0 -1
- package/lib/Common/Request.js +0 -18
- package/lib/Common/Request.js.map +0 -1
- package/lib/Common/Response.d.ts +0 -60
- package/lib/Common/Response.d.ts.map +0 -1
- package/lib/Common/Response.js +0 -42
- package/lib/Common/Response.js.map +0 -1
- package/lib/Common/index.d.ts +0 -20
- package/lib/Common/index.d.ts.map +0 -1
- package/lib/Common/index.js +0 -36
- package/lib/Common/index.js.map +0 -1
- package/lib/Encoder/Decoder.d.ts +0 -18
- package/lib/Encoder/Decoder.d.ts.map +0 -1
- package/lib/Encoder/Decoder.js +0 -136
- package/lib/Encoder/Decoder.js.map +0 -1
- package/lib/Encoder/Encoder.d.ts +0 -18
- package/lib/Encoder/Encoder.d.ts.map +0 -1
- package/lib/Encoder/Encoder.js +0 -35
- package/lib/Encoder/Encoder.js.map +0 -1
- package/lib/Encoder/Errors.d.ts +0 -17
- package/lib/Encoder/Errors.d.ts.map +0 -1
- package/lib/Encoder/Errors.js +0 -26
- package/lib/Encoder/Errors.js.map +0 -1
- package/lib/Errors.d.ts +0 -20
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js +0 -40
- package/lib/Errors.js.map +0 -1
- package/lib/Server/Common/Gateway.d.ts +0 -26
- package/lib/Server/Common/Gateway.d.ts.map +0 -1
- package/lib/Server/Common/Gateway.js +0 -18
- package/lib/Server/Common/Gateway.js.map +0 -1
- package/lib/Server/Common/Request.d.ts +0 -21
- package/lib/Server/Common/Request.d.ts.map +0 -1
- package/lib/Server/Common/Request.js +0 -18
- package/lib/Server/Common/Request.js.map +0 -1
- package/lib/Server/Common/Router.d.ts +0 -41
- package/lib/Server/Common/Router.d.ts.map +0 -1
- package/lib/Server/Common/Router.js +0 -18
- package/lib/Server/Common/Router.js.map +0 -1
- package/lib/Server/Common/Server.d.ts +0 -57
- package/lib/Server/Common/Server.d.ts.map +0 -1
- package/lib/Server/Common/Server.js +0 -18
- package/lib/Server/Common/Server.js.map +0 -1
- package/lib/Server/Common/index.d.ts +0 -20
- package/lib/Server/Common/index.d.ts.map +0 -1
- package/lib/Server/Common/index.js +0 -36
- package/lib/Server/Common/index.js.map +0 -1
- package/lib/Server/Errors.d.ts +0 -25
- package/lib/Server/Errors.d.ts.map +0 -1
- package/lib/Server/Errors.js +0 -74
- package/lib/Server/Errors.js.map +0 -1
- package/lib/Server/Gateways/Http.d.ts +0 -18
- package/lib/Server/Gateways/Http.d.ts.map +0 -1
- package/lib/Server/Gateways/Http.js +0 -148
- package/lib/Server/Gateways/Http.js.map +0 -1
- package/lib/Server/Gateways/TCP.d.ts +0 -23
- package/lib/Server/Gateways/TCP.d.ts.map +0 -1
- package/lib/Server/Gateways/TCP.js +0 -146
- package/lib/Server/Gateways/TCP.js.map +0 -1
- package/lib/Server/Server.d.ts +0 -18
- package/lib/Server/Server.d.ts.map +0 -1
- package/lib/Server/Server.js +0 -200
- package/lib/Server/Server.js.map +0 -1
- package/lib/Server/SimpleRouter.d.ts +0 -41
- package/lib/Server/SimpleRouter.d.ts.map +0 -1
- package/lib/Server/SimpleRouter.js +0 -54
- package/lib/Server/SimpleRouter.js.map +0 -1
- package/lib/Server/index.d.ts +0 -22
- package/lib/Server/index.d.ts.map +0 -1
- package/lib/Server/index.js +0 -38
- package/lib/Server/index.js.map +0 -1
- package/src/lib/Client/BuiltInRIDGenerator.ts +0 -21
- package/src/lib/Client/Common.ts +0 -63
- package/src/lib/Client/Errors.ts +0 -87
- package/src/lib/Client/HttpClient.ts +0 -232
- package/src/lib/Client/HttpsClient.ts +0 -238
- package/src/lib/Client/TCPClient.ts +0 -420
- package/src/lib/Client/TLSClient.ts +0 -422
- package/src/lib/Client/index.ts +0 -23
- package/src/lib/Common/API.ts +0 -20
- package/src/lib/Common/Encoding.ts +0 -42
- package/src/lib/Common/Request.ts +0 -28
- package/src/lib/Common/Response.ts +0 -67
- package/src/lib/Common/index.ts +0 -20
- package/src/lib/Encoder/Decoder.ts +0 -206
- package/src/lib/Encoder/Encoder.ts +0 -41
- package/src/lib/Encoder/Errors.ts +0 -24
- package/src/lib/Errors.ts +0 -40
- package/src/lib/Server/Common/Gateway.ts +0 -37
- package/src/lib/Server/Common/Request.ts +0 -24
- package/src/lib/Server/Common/Router.ts +0 -52
- package/src/lib/Server/Common/Server.ts +0 -68
- package/src/lib/Server/Common/index.ts +0 -20
- package/src/lib/Server/Errors.ts +0 -80
- package/src/lib/Server/Gateways/Http.ts +0 -209
- package/src/lib/Server/Gateways/TCP.ts +0 -221
- package/src/lib/Server/Server.ts +0 -268
- package/src/lib/Server/SimpleRouter.ts +0 -95
- package/src/lib/Server/index.ts +0 -22
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as $Http from 'http';
|
|
18
|
+
import * as $Https from 'https';
|
|
19
|
+
import * as C from './Client.decl';
|
|
20
|
+
import * as Shared from '../shared';
|
|
21
|
+
import * as v1 from '../shared/Encodings/v1';
|
|
22
|
+
import { EventEmitter } from 'node:events';
|
|
23
|
+
|
|
24
|
+
const HTTP_HEADER_CONTENT_LENGTH = 'content-length';
|
|
25
|
+
const HTTP_HEADER_TV_VER = 'x-tv-ver';
|
|
26
|
+
|
|
27
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
28
|
+
|
|
29
|
+
const disabledStreamManager = Shared.createDisabledStreamManagerFactory()(null as any);
|
|
30
|
+
|
|
31
|
+
class TvLegacyHttpClient extends EventEmitter implements C.IClient<any> {
|
|
32
|
+
|
|
33
|
+
public onError!: any;
|
|
34
|
+
|
|
35
|
+
public constructor(
|
|
36
|
+
private readonly _request: (opts: any, cb: (resp: $Http.IncomingMessage) => void) => $Http.ClientRequest,
|
|
37
|
+
private readonly _opts: $Https.RequestOptions,
|
|
38
|
+
private readonly _agent: $Http.Agent,
|
|
39
|
+
private readonly _apiNameWrapper?: (name: string) => string
|
|
40
|
+
) {
|
|
41
|
+
|
|
42
|
+
super();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public get timeout(): number {
|
|
46
|
+
|
|
47
|
+
return this._opts.timeout ?? DEFAULT_TIMEOUT;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get streams(): Shared.IStreamManager {
|
|
51
|
+
|
|
52
|
+
return disabledStreamManager;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public readonly writable: boolean = true;
|
|
56
|
+
|
|
57
|
+
public readonly ended: boolean = false;
|
|
58
|
+
|
|
59
|
+
public readonly finished: boolean = false;
|
|
60
|
+
|
|
61
|
+
public readonly transporter = null;
|
|
62
|
+
|
|
63
|
+
public sendBinaryChunk(): Promise<void> {
|
|
64
|
+
|
|
65
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public sendMessage(): Promise<void> {
|
|
69
|
+
|
|
70
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public ping(): Promise<Buffer> {
|
|
74
|
+
|
|
75
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public invoke(api: any, ...args: any[]): Promise<any> {
|
|
79
|
+
|
|
80
|
+
const CST = Date.now();
|
|
81
|
+
|
|
82
|
+
const content = JSON.stringify({
|
|
83
|
+
ttl: this._opts.timeout ?? DEFAULT_TIMEOUT,
|
|
84
|
+
rid: 0,
|
|
85
|
+
cst: CST,
|
|
86
|
+
args,
|
|
87
|
+
api: this._apiNameWrapper ? this._apiNameWrapper(api) : api
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
|
|
92
|
+
const length = Buffer.byteLength(content);
|
|
93
|
+
|
|
94
|
+
if (length > v1.MAX_PACKET_SIZE) {
|
|
95
|
+
|
|
96
|
+
reject(new Shared.errors.invalid_packet({ reason: 'packet_too_large' }));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const req = this._request({
|
|
101
|
+
...this._opts,
|
|
102
|
+
agent: this._agent,
|
|
103
|
+
method: 'POST',
|
|
104
|
+
headers: {
|
|
105
|
+
...this._opts.headers,
|
|
106
|
+
[HTTP_HEADER_CONTENT_LENGTH]: Buffer.byteLength(content),
|
|
107
|
+
[HTTP_HEADER_TV_VER]: 1
|
|
108
|
+
},
|
|
109
|
+
}, (resp) => {
|
|
110
|
+
|
|
111
|
+
if (!resp.headers[HTTP_HEADER_CONTENT_LENGTH]) {
|
|
112
|
+
|
|
113
|
+
reject(new Shared.errors.invalid_response());
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const length = parseInt(resp.headers[HTTP_HEADER_CONTENT_LENGTH]);
|
|
118
|
+
|
|
119
|
+
if (!Number.isSafeInteger(length) || length > v1.MAX_PACKET_SIZE) { // Maximum request packet is 64MB
|
|
120
|
+
|
|
121
|
+
reject(new Shared.errors.invalid_packet({ reason: 'packet_too_large' }));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const buf = Buffer.allocUnsafe(length);
|
|
126
|
+
|
|
127
|
+
let offset: number = 0;
|
|
128
|
+
|
|
129
|
+
resp.on('data', (chunk: Buffer) => {
|
|
130
|
+
|
|
131
|
+
const index = offset;
|
|
132
|
+
|
|
133
|
+
offset += chunk.byteLength;
|
|
134
|
+
|
|
135
|
+
if (offset > length) {
|
|
136
|
+
|
|
137
|
+
resp.removeAllListeners('end');
|
|
138
|
+
resp.removeAllListeners('data');
|
|
139
|
+
resp.destroy();
|
|
140
|
+
|
|
141
|
+
reject(new Shared.errors.invalid_packet({ reason: 'packet_length_mismatched' }));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
chunk.copy(buf, index);
|
|
146
|
+
|
|
147
|
+
}).on('end', () => {
|
|
148
|
+
|
|
149
|
+
let data: v1.IResponsePayloadV1;
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
|
|
153
|
+
data = JSON.parse(buf as any);
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
|
|
157
|
+
reject(new Shared.errors.invalid_response({
|
|
158
|
+
reason: 'invalid_json',
|
|
159
|
+
raw: buf
|
|
160
|
+
}, e));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
switch (data.code) {
|
|
165
|
+
case v1.EResponseCode.OK:
|
|
166
|
+
resolve(data.body);
|
|
167
|
+
break;
|
|
168
|
+
case v1.EResponseCode.FAILURE:
|
|
169
|
+
reject(new Shared.TvErrorResponse(data.body));
|
|
170
|
+
break;
|
|
171
|
+
case v1.EResponseCode.API_NOT_FOUND:
|
|
172
|
+
reject(new Shared.errors.api_not_found({ api }));
|
|
173
|
+
break;
|
|
174
|
+
case v1.EResponseCode.MALFORMED_ARGUMENTS:
|
|
175
|
+
case v1.EResponseCode.SYSTEM_ERROR:
|
|
176
|
+
default:
|
|
177
|
+
reject(new Shared.errors.unknown({
|
|
178
|
+
api, ...data
|
|
179
|
+
}));
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
req.once('timeout', () => {
|
|
186
|
+
reject(new Shared.errors.timeout({
|
|
187
|
+
metadata: { api, time: Date.now(), details: null }
|
|
188
|
+
}));
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
req.once('error', reject);
|
|
192
|
+
|
|
193
|
+
req.end(content);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public connect(): Promise<void> {
|
|
198
|
+
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public close(): Promise<void> {
|
|
203
|
+
|
|
204
|
+
this._agent.destroy();
|
|
205
|
+
|
|
206
|
+
return Promise.resolve();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface IHttpClientNetworkOptions extends $Https.RequestOptions {
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Whether to use HTTPS.
|
|
214
|
+
*
|
|
215
|
+
* @default false
|
|
216
|
+
*/
|
|
217
|
+
https?: boolean;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The hostname of HTTP server.
|
|
221
|
+
*
|
|
222
|
+
* @default 'localhost'
|
|
223
|
+
*/
|
|
224
|
+
hostname: string;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The port of HTTP server.
|
|
228
|
+
*
|
|
229
|
+
* @default 80 or 443
|
|
230
|
+
*/
|
|
231
|
+
port?: number;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* The path to the RPC entry.
|
|
235
|
+
*
|
|
236
|
+
* @default '/'
|
|
237
|
+
*/
|
|
238
|
+
path?: string;
|
|
239
|
+
|
|
240
|
+
apiNameWrapper?: (name: string) => string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface IHttpClientUnixSocketOptions extends $Https.RequestOptions {
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Whether to use HTTPS.
|
|
247
|
+
*
|
|
248
|
+
* > Always `false` for Unix domain socket.
|
|
249
|
+
*/
|
|
250
|
+
https?: false;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The path of Unix domain socket to connect to.
|
|
254
|
+
*/
|
|
255
|
+
socketPath: string;
|
|
256
|
+
|
|
257
|
+
apiNameWrapper?: (name: string) => string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export type IHttpClientOptions = IHttpClientNetworkOptions | IHttpClientUnixSocketOptions;
|
|
261
|
+
|
|
262
|
+
export function createLegacyHttpClient<TAPIs extends Shared.IObject>(opts: IHttpClientOptions): C.IClient<TAPIs> {
|
|
263
|
+
|
|
264
|
+
return new TvLegacyHttpClient(
|
|
265
|
+
opts.https ? $Https.request : $Http.request,
|
|
266
|
+
opts,
|
|
267
|
+
opts.https ? new $Https.Agent({
|
|
268
|
+
maxSockets: 0,
|
|
269
|
+
keepAlive: true,
|
|
270
|
+
keepAliveMsecs: DEFAULT_TIMEOUT
|
|
271
|
+
}) : new $Http.Agent({
|
|
272
|
+
maxSockets: 0,
|
|
273
|
+
keepAlive: true,
|
|
274
|
+
keepAliveMsecs: DEFAULT_TIMEOUT
|
|
275
|
+
}),
|
|
276
|
+
opts.apiNameWrapper
|
|
277
|
+
);
|
|
278
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from './Client.decl';
|
|
18
|
+
export * from './JsonApiClient.impl';
|
|
19
|
+
export * from './LegacyHttpClient.impl';
|
package/src/lib/index.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
16
|
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './Errors';
|
|
22
|
-
export * from './Client';
|
|
17
|
+
export * from './shared';
|
|
18
|
+
export * as Servers from './server';
|
|
19
|
+
export * as Clients from './client';
|
|
20
|
+
export * as Gateways from './transporters';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as Shared from '../shared';
|
|
18
|
+
import { EventEmitter } from 'node:events';
|
|
19
|
+
import * as v2 from '../shared/Encodings/v2';
|
|
20
|
+
|
|
21
|
+
export type ILegacyApiResponseCallback = (body: v2.IDataChunkField | Shared.TelevokeError) => void;
|
|
22
|
+
|
|
23
|
+
const streamManager = Shared.createDisabledStreamManagerFactory()(null as any);
|
|
24
|
+
|
|
25
|
+
export class TvLegacyServerChannelV1 extends EventEmitter implements Shared.IChannelBase<Shared.IDefaultEvents> {
|
|
26
|
+
|
|
27
|
+
public get context(): Record<string, unknown> { return {}; }
|
|
28
|
+
|
|
29
|
+
public get ended(): boolean { return false; }
|
|
30
|
+
|
|
31
|
+
public get finished(): boolean { return false; }
|
|
32
|
+
|
|
33
|
+
public get writable(): boolean { return false; }
|
|
34
|
+
|
|
35
|
+
public get id(): number { return 0; }
|
|
36
|
+
|
|
37
|
+
public get timeout(): number { return 30_000; }
|
|
38
|
+
|
|
39
|
+
public get streams(): Shared.IStreamManager { return streamManager; }
|
|
40
|
+
|
|
41
|
+
public constructor(
|
|
42
|
+
public readonly transporter: Shared.ITransporter
|
|
43
|
+
) {
|
|
44
|
+
super();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public openBinaryStream(): Shared.IBinaryReadStream {
|
|
48
|
+
|
|
49
|
+
throw new Shared.errors.cmd_not_impl();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public ping(): Promise<Buffer> {
|
|
53
|
+
|
|
54
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public sendBinaryChunk(): Promise<void> {
|
|
58
|
+
|
|
59
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public sendMessage(): Promise<void> {
|
|
63
|
+
|
|
64
|
+
return Promise.reject(new Shared.errors.cmd_not_impl());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public close(): void {
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as Shared from '../shared';
|
|
18
|
+
|
|
19
|
+
export interface IChannelEvents extends Shared.IDefaultEvents {
|
|
20
|
+
|
|
21
|
+
close(): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IChannel extends Shared.IChannelBase<IChannelEvents> {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The channel id.
|
|
28
|
+
*/
|
|
29
|
+
readonly id: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IRequestContext {
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The channel which the request comes from.
|
|
36
|
+
*/
|
|
37
|
+
readonly channel: IChannel;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type IRouteApiCallback = (response: string | Buffer | Array<string | Buffer> | Shared.TelevokeError) => void;
|
|
41
|
+
|
|
42
|
+
export type IRouteLegacyApiCallback = (response: unknown | Shared.TvErrorResponse | Shared.TelevokeError) => void;
|
|
43
|
+
|
|
44
|
+
export interface IRouter {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The encoding of the API request/response.
|
|
48
|
+
*/
|
|
49
|
+
readonly encoding: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Process an API call.
|
|
53
|
+
*
|
|
54
|
+
* @param cb The callback function of processing result.
|
|
55
|
+
* @param name The API name.
|
|
56
|
+
* @param args The API arguments.
|
|
57
|
+
* @param context The request context.
|
|
58
|
+
*/
|
|
59
|
+
processApi(
|
|
60
|
+
cb: IRouteApiCallback,
|
|
61
|
+
name: string,
|
|
62
|
+
args: Buffer[],
|
|
63
|
+
context: IRequestContext
|
|
64
|
+
): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Process an API call from legacy client.
|
|
68
|
+
*
|
|
69
|
+
* @param cb The callback function of processing result.
|
|
70
|
+
* @param name The API name.
|
|
71
|
+
* @param args The API arguments.
|
|
72
|
+
* @param context The request context.
|
|
73
|
+
*/
|
|
74
|
+
processLegacyApi(
|
|
75
|
+
cb: IRouteLegacyApiCallback,
|
|
76
|
+
name: string,
|
|
77
|
+
args: unknown,
|
|
78
|
+
context: IRequestContext
|
|
79
|
+
): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface IServerEvents extends Shared.IDefaultEvents {
|
|
83
|
+
|
|
84
|
+
channel(channel: IChannel): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface IServer extends Shared.IEventListener<IServerEvents> {
|
|
88
|
+
|
|
89
|
+
readonly router: IRouter;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The timeout for waiting replies of each command sent to the remote endpoint, in milliseconds.
|
|
93
|
+
*
|
|
94
|
+
* @default 60000
|
|
95
|
+
*/
|
|
96
|
+
timeout: number;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get the channel object by Id.
|
|
100
|
+
*
|
|
101
|
+
* @param channelId The channel Id.
|
|
102
|
+
*/
|
|
103
|
+
getChannel(channelId: string): IChannel | null;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the Id list of all alive channels.
|
|
107
|
+
*/
|
|
108
|
+
getChannelIdList(): string[];
|
|
109
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type * as dS from './Server.decl';
|
|
18
|
+
import * as Shared from '../shared';
|
|
19
|
+
import type * as dT from '../transporters/Transporter.decl';
|
|
20
|
+
import { EventEmitter } from 'node:events';
|
|
21
|
+
import { IChannelEvents } from '../shared/Channel.impl';
|
|
22
|
+
import { TvServerChannelV2 } from './ServerChannel';
|
|
23
|
+
import { TvLegacyServerChannelV1 } from './LegacyServerChannel.impl';
|
|
24
|
+
|
|
25
|
+
let nextChId = Date.now();
|
|
26
|
+
|
|
27
|
+
export class TvServer extends EventEmitter implements dS.IServer, dT.IServer {
|
|
28
|
+
|
|
29
|
+
private readonly _channels: Record<string, dS.IChannel> = {};
|
|
30
|
+
|
|
31
|
+
public timeout = 60_000;
|
|
32
|
+
|
|
33
|
+
public constructor(
|
|
34
|
+
public router: dS.IRouter,
|
|
35
|
+
private readonly _streamManagerFactory: Shared.IStreamManagerFactory = Shared.createSharedStreamManagerFactory()
|
|
36
|
+
) {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setRouter(router: dS.IRouter): void {
|
|
41
|
+
|
|
42
|
+
this.router = router;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public registerChannel(transporter: dT.ITransporter): void {
|
|
46
|
+
|
|
47
|
+
const id = nextChId++;
|
|
48
|
+
|
|
49
|
+
this._channels[id] = new TvServerChannelV2(
|
|
50
|
+
id,
|
|
51
|
+
transporter as any,
|
|
52
|
+
this.timeout,
|
|
53
|
+
this._streamManagerFactory
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
(this._channels[id] as Shared.IChannelBase<IChannelEvents>)
|
|
57
|
+
.on('api_call', (cb, name, body) => {
|
|
58
|
+
this.router.processApi(cb, name, body, {
|
|
59
|
+
channel: this._channels[id],
|
|
60
|
+
});
|
|
61
|
+
})
|
|
62
|
+
.on('error', (err) => this.emit('error', err))
|
|
63
|
+
.on('close', () => { delete this._channels[id]; });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public processLegacyApi(
|
|
67
|
+
callback: dT.ILegacyApiResponseCallback,
|
|
68
|
+
name: string,
|
|
69
|
+
args: unknown,
|
|
70
|
+
transporter: Shared.ITransporter
|
|
71
|
+
): void {
|
|
72
|
+
|
|
73
|
+
this.router.processLegacyApi(
|
|
74
|
+
callback,
|
|
75
|
+
name,
|
|
76
|
+
args,
|
|
77
|
+
{ 'channel': new TvLegacyServerChannelV1(transporter) }
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public getChannel(id: string): dS.IChannel | null {
|
|
82
|
+
|
|
83
|
+
return this._channels[id] ?? null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public getChannelIdList(): string[] {
|
|
87
|
+
|
|
88
|
+
return Object.keys(this._channels);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type * as dS from './Server.decl';
|
|
18
|
+
import { AbstractTvChannelV2 } from '../shared/Channel.impl';
|
|
19
|
+
|
|
20
|
+
export class TvServerChannelV2 extends AbstractTvChannelV2 implements dS.IChannel {}
|