@asyncapi/generator 2.8.0 → 2.8.3
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/CHANGELOG.md +18 -0
- package/docs/api.md +1 -2
- package/lib/templates/BakedInTemplatesList.json +7 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/README.md +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientClass.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientFields.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Connect.js +60 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Constructor.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/HandleMessage.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/RegisterErrorHandler.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/SendEchoMessage.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/SendEchoMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/client.dart.js +181 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/client.dart.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/pubspec.yaml.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/pubspec.yaml.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/ClientClass.js +32 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/ClientFields.js +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Connect.js +49 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Constructor.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/HandleMessage.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/RegisterErrorHandler.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/SendEchoMessage.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/example.dart +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +55 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/client.dart.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/pubspec.yaml.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/README.md +28 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientConnector.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientConnector.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientFields.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ConnectorFields.js +22 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ConnectorFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/EchoWebSocket.js +40 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/EchoWebSocket.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/HandleError.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/HandleError.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/InitConnector.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/InitConnector.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnClose.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnClose.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnOpen.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnOpen.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnTextMessageHandler.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnTextMessageHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ClientDependencies.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ClientDependencies.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ConnectorDependencies.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ConnectorDependencies.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/client.java.js +154 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/client.java.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/connector.java.js +108 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/connector.java.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/models/model.js +52 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/models/model.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/resources/AppProperties.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/resources/AppProperties.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ClientConnector.js +17 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ClientFields.js +10 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ConnectorFields.js +11 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/EchoWebSocket.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/HandleError.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/InitConnector.js +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnClose.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnOpen.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnTextMessageHandler.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/dependencies/ClientDependencies.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/dependencies/ConnectorDependencies.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +64 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.dockerignore +5 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.mvn/wrapper/MavenWrapperDownloader.java +93 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.mvn/wrapper/maven-wrapper.properties +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/README.md +58 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/mvnw +332 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/mvnw.cmd +206 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/pom.xml +125 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/docker/Dockerfile.jvm +98 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/client.java.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/connector.java.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/models/model.js +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/resources/AppProperties.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/README.md +10 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js +34 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Connect.js +63 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/HandleMessage.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ModuleExport.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ModuleExport.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/RegisterErrorHandler.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/SendOperation.js +53 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/SendOperation.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/example.js +43 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/example.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js +166 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +216 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/AvailableOperations.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ClientClass.js +32 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Connect.js +54 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Constructor.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/HandleMessage.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/MessageExamples.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ModuleExport.js +11 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/OperationHeader.js +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/RegisterErrorHandler.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/SendOperation.js +44 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/example.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +55 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/README.md.js +106 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/client.js.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/README.md +53 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/ClientClass.js +61 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Connect.js +58 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Constructor.js +55 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleError.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleError.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleMessage.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/InitSignature.js +34 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/InitSignature.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsArgumentsDocs.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsArgumentsDocs.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsVariables.js +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsVariables.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterErrorHandler.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterOutgoingProcessor.js +26 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterOutgoingProcessor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Requires.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Requires.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Send.js +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Send.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/SendOperation.js +56 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/SendOperation.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/client.py.js +379 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/client.py.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/models.js +15 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/models.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/requirements.txt.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/requirements.txt.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/ClientClass.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Connect.js +49 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Constructor.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/HandleError.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/HandleMessage.js +17 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/InitSignature.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/QueryParamsArgumentsDocs.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/QueryParamsVariables.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/RegisterErrorHandler.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/RegisterOutgoingProcessor.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Requires.js +15 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Send.js +33 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/SendOperation.js +50 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/example-slack.py +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/example.py +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +55 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/client.py.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/models.js +5 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/requirements.txt.js +13 -0
- package/package.json +6 -3
package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Connect.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function Connect({ title }) {
|
|
4
|
+
return (
|
|
5
|
+
<Text newLines={2} indent={2}>
|
|
6
|
+
{`/// Method to establish a WebSocket connection
|
|
7
|
+
Future<void> connect() async {
|
|
8
|
+
if (_channel != null) {
|
|
9
|
+
print('Already connected to ${title} server');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
final wsUrl = Uri.parse(_url);
|
|
14
|
+
_channel = WebSocketChannel.connect(wsUrl);
|
|
15
|
+
print('Connected to ${title} server');
|
|
16
|
+
|
|
17
|
+
/// Listen to the incoming message stream
|
|
18
|
+
_channel?.stream.listen(
|
|
19
|
+
(message) {
|
|
20
|
+
if (_messageHandlers.isNotEmpty) {
|
|
21
|
+
for (var handler in _messageHandlers) {
|
|
22
|
+
_handleMessage(message, handler);
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
print('Message received: $message');
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onError: (error) {
|
|
29
|
+
if (_errorHandlers.isNotEmpty) {
|
|
30
|
+
for (var handler in _errorHandlers) {
|
|
31
|
+
handler(error);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
print('WebSocket Error: $error');
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
onDone: () {
|
|
38
|
+
_channel = null;
|
|
39
|
+
print('Disconnected from ${title} server');
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
print('Connection failed: $error');
|
|
44
|
+
rethrow;
|
|
45
|
+
}
|
|
46
|
+
}`}
|
|
47
|
+
</Text>
|
|
48
|
+
);
|
|
49
|
+
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Constructor.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function Constructor({ clientName, serverUrl }) {
|
|
4
|
+
return (
|
|
5
|
+
<Text newLines={2} indent={2}>
|
|
6
|
+
{
|
|
7
|
+
`
|
|
8
|
+
/// Constructor to initialize the WebSocket client
|
|
9
|
+
///
|
|
10
|
+
/// [url] - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.
|
|
11
|
+
${clientName}({String? url})
|
|
12
|
+
: _url = url ?? '${serverUrl}';
|
|
13
|
+
`}
|
|
14
|
+
</Text>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function HandleMessage() {
|
|
4
|
+
return (
|
|
5
|
+
<Text newLines={2} indent={2}>
|
|
6
|
+
{
|
|
7
|
+
`/// Method to handle message with callback
|
|
8
|
+
void _handleMessage(dynamic message, void Function(String) cb) {
|
|
9
|
+
cb(message is String ? message : message.toString());
|
|
10
|
+
}`
|
|
11
|
+
}
|
|
12
|
+
</Text>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function RegisterErrorHandler() {
|
|
4
|
+
return (
|
|
5
|
+
<Text newLines={2} indent={2}>
|
|
6
|
+
{
|
|
7
|
+
`/// Method to register custom error handlers
|
|
8
|
+
void registerErrorHandler(void Function(Object) handler) {
|
|
9
|
+
_errorHandlers.add(handler);
|
|
10
|
+
}`
|
|
11
|
+
}
|
|
12
|
+
</Text>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function SendEchoMessage() {
|
|
4
|
+
return (
|
|
5
|
+
<Text newLines={2} indent={2}>
|
|
6
|
+
{
|
|
7
|
+
`/// Method to send an echo message to the server
|
|
8
|
+
void sendEchoMessage(dynamic message) {
|
|
9
|
+
if (_channel == null) {
|
|
10
|
+
print('Error: WebSocket is not connected.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
final payload = message is String ? message : jsonEncode(message);
|
|
14
|
+
_channel!.sink.add(payload);
|
|
15
|
+
print('Sent message to echo server: $payload');
|
|
16
|
+
}`
|
|
17
|
+
}
|
|
18
|
+
</Text>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import 'dart:async';
|
|
2
|
+
import 'test/temp/snapshotTestResult/custom_client_hoppscotch/client.dart';
|
|
3
|
+
|
|
4
|
+
void myHandler(String message) {
|
|
5
|
+
print('====================');
|
|
6
|
+
print('Just proving I got the message in myHandler: $message');
|
|
7
|
+
print('====================');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
void myErrorHandler(Object error) {
|
|
11
|
+
print('Errors from WebSocket: $error');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Future<void> main() async {
|
|
15
|
+
final wsClient = HoppscotchClient();
|
|
16
|
+
wsClient.registerMessageHandler(myHandler);
|
|
17
|
+
wsClient.registerErrorHandler(myErrorHandler);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
await wsClient.connect();
|
|
21
|
+
|
|
22
|
+
const interval = Duration(seconds: 5);
|
|
23
|
+
const message = 'Hello, Echo!';
|
|
24
|
+
|
|
25
|
+
while (true) {
|
|
26
|
+
try {
|
|
27
|
+
wsClient.sendEchoMessage(message);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
print('Error while sending message: $error');
|
|
30
|
+
}
|
|
31
|
+
await Future.delayed(interval);
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
print('Failed to connect to WebSocket: $error');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "core-template-client-websocket-dart",
|
|
3
|
+
"private": true,
|
|
4
|
+
"description": "This is a template generating Dart websocket client",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "jest --coverage --passWithNoTests",
|
|
7
|
+
"test:update": "npm run test -- -u",
|
|
8
|
+
"lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
|
|
9
|
+
"lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
|
|
10
|
+
},
|
|
11
|
+
"author": "Adi Boghawala <boghawalaadi@gmail.com>",
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@asyncapi/generator-react-sdk": "*",
|
|
15
|
+
"@asyncapi/generator-helpers": "0.2.0",
|
|
16
|
+
"@asyncapi/generator-components": "0.2.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@asyncapi/parser": "^3.0.14",
|
|
20
|
+
"@babel/cli": "^7.25.9",
|
|
21
|
+
"@babel/core": "^7.26.0",
|
|
22
|
+
"@babel/preset-env": "^7.26.0",
|
|
23
|
+
"@babel/preset-react": "^7.25.9",
|
|
24
|
+
"jest-esm-transformer": "^1.0.0",
|
|
25
|
+
"eslint": "^6.8.0",
|
|
26
|
+
"eslint-plugin-jest": "^23.8.2",
|
|
27
|
+
"eslint-plugin-react": "^7.34.1",
|
|
28
|
+
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
|
+
},
|
|
30
|
+
"jest": {
|
|
31
|
+
"moduleFileExtensions": [
|
|
32
|
+
"js",
|
|
33
|
+
"json",
|
|
34
|
+
"jsx"
|
|
35
|
+
],
|
|
36
|
+
"transform": {
|
|
37
|
+
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
+
},
|
|
39
|
+
"moduleNameMapper": {
|
|
40
|
+
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
+
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"babel": {
|
|
45
|
+
"presets": [
|
|
46
|
+
"@babel/preset-env",
|
|
47
|
+
[
|
|
48
|
+
"@babel/preset-react",
|
|
49
|
+
{
|
|
50
|
+
"runtime": "automatic"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/client.dart.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { File } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
import { getClientName, getServerUrl, getServer, getInfo, getTitle } from '@asyncapi/generator-helpers';
|
|
3
|
+
import { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';
|
|
4
|
+
import { ClientClass } from '../components/ClientClass';
|
|
5
|
+
|
|
6
|
+
export default function ({ asyncapi, params }) {
|
|
7
|
+
const server = getServer(asyncapi.servers(), params.server);
|
|
8
|
+
const info = getInfo(asyncapi);
|
|
9
|
+
const title = getTitle(asyncapi);
|
|
10
|
+
const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
11
|
+
const serverUrl = getServerUrl(server);
|
|
12
|
+
return (
|
|
13
|
+
// The clientFileName default values can be found and modified under the package.json
|
|
14
|
+
<File name={params.clientFileName}>
|
|
15
|
+
<FileHeaderInfo
|
|
16
|
+
info={info}
|
|
17
|
+
server={server}
|
|
18
|
+
language="dart"
|
|
19
|
+
/>
|
|
20
|
+
<DependencyProvider language="dart" />
|
|
21
|
+
<ClientClass clientName={clientName} serverUrl={serverUrl} title={title} />
|
|
22
|
+
</File>
|
|
23
|
+
);
|
|
24
|
+
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/pubspec.yaml.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { File, Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
return (
|
|
5
|
+
<File name="pubspec.yaml">
|
|
6
|
+
<Text>
|
|
7
|
+
{`name: wsclient
|
|
8
|
+
environment:
|
|
9
|
+
sdk: '>=3.0.0 <4.0.0'
|
|
10
|
+
dependencies:
|
|
11
|
+
web_socket_channel: ^3.0.2`
|
|
12
|
+
}
|
|
13
|
+
</Text>
|
|
14
|
+
</File>
|
|
15
|
+
);
|
|
16
|
+
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
renderer: react
|
|
2
|
+
apiVersion: v3
|
|
3
|
+
generator: '>=1.3.0 <3.0.0'
|
|
4
|
+
parameters:
|
|
5
|
+
server:
|
|
6
|
+
description: The name of the server described in AsyncAPI document
|
|
7
|
+
required: false
|
|
8
|
+
appendClientSuffix:
|
|
9
|
+
description: Add 'Client' suffix at the end of the class name. This option has no effect if 'customClientName' is specified.
|
|
10
|
+
required: false
|
|
11
|
+
default: false
|
|
12
|
+
customClientName:
|
|
13
|
+
description: The custom name for the generated client class
|
|
14
|
+
required: false
|
|
15
|
+
nonRenderableFiles:
|
|
16
|
+
- .dockerignore
|
|
17
|
+
- .gitignore
|
|
18
|
+
- .mvn/**
|
|
19
|
+
- mvnw
|
|
20
|
+
- mvnw.cmd
|
|
21
|
+
metadata:
|
|
22
|
+
type: client
|
|
23
|
+
protocol: websocket
|
|
24
|
+
target: java
|
|
25
|
+
stack: quarkus
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
## Java Quarkus WebSocket Client
|
|
3
|
+
|
|
4
|
+
You can test this template (for now modifications are coming):
|
|
5
|
+
1. Clone the project and run `npm install`
|
|
6
|
+
2. Navigate to `packages/templates/clients/websocket/test/integration-test` and run the tests with `npm run test` to generate WebSocket clients
|
|
7
|
+
3. Navigate to `packages/templates/clients/websocket/java/quarkus`
|
|
8
|
+
4. Install dependencies with `npm install`
|
|
9
|
+
5. Navigate to the generated clients in the folder with `cd test/temp/snapshotTestResult`
|
|
10
|
+
6. Pick a generated client inside one of the folders and navigate to source code with `cd /client_postman`
|
|
11
|
+
7. Run the templated client with `mvn quarkus:dev`
|
|
12
|
+
8. See the output in the terminal
|
|
13
|
+
|
|
14
|
+
## Generate client with custom AsyncAPI document
|
|
15
|
+
|
|
16
|
+
2. Navigate to `packages/templates/clients/websocket/java/quarkus`
|
|
17
|
+
3. Install with `npm install`
|
|
18
|
+
4. Navigate back to `./generator`
|
|
19
|
+
5. Generate the template client with `node .\apps\generator\cli.js <path-to-custom-document> .\packages\templates\clients\websocket\java\quarkus\ -o outputClient --force-write --param server=<custom-server>`
|
|
20
|
+
6. Navigate to `outputClient` or any other name you gave the output folder
|
|
21
|
+
7. Run `mvn quarkus:dev`
|
|
22
|
+
8. See the output in the terminal
|
|
23
|
+
|
|
24
|
+
## **NOTE:**
|
|
25
|
+
- Currently only supports asyncapi-postman-echo.yml AsyncApi Document
|
|
26
|
+
|
|
27
|
+
## Todo
|
|
28
|
+
- Support slack AsyncAPI document
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var InitConnector = require('./InitConnector.js');
|
|
6
|
+
var ConnectorFields = require('./ConnectorFields.js');
|
|
7
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
|
+
|
|
9
|
+
function ClientConnector({
|
|
10
|
+
clientName
|
|
11
|
+
}) {
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.Text, {
|
|
13
|
+
newLines: 2,
|
|
14
|
+
indent: 2,
|
|
15
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
16
|
+
newLines: 2,
|
|
17
|
+
children: `@Startup
|
|
18
|
+
@Singleton
|
|
19
|
+
public class ${clientName}Connector{`
|
|
20
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ConnectorFields.ConnectorFields, {
|
|
21
|
+
clientName: clientName
|
|
22
|
+
}), /*#__PURE__*/jsxRuntime.jsx(InitConnector, {})]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = ClientConnector;
|
|
27
|
+
//# sourceMappingURL=ClientConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientConnector.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/ClientConnector.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\nimport InitConnector from './InitConnector';\nimport { ConnectorFields } from './ConnectorFields';\n\nexport default function ClientConnector({ clientName }) {\n return (\n <Text newLines={2} indent={2}>\n <Text newLines={2}>\n {`@Startup\n@Singleton \npublic class ${clientName}Connector{`}\n </Text>\n <ConnectorFields clientName={clientName} />\n <InitConnector />\n </Text>\n );\n}"],"names":["ClientConnector","clientName","_jsxs","Text","newLines","indent","children","_jsx","ConnectorFields","InitConnector"],"mappings":";;;;;;;;AAIe,SAASA,eAAeA,CAAC;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;EACtD,oBACEC,eAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;IAAAC,QAAA,EAAA,cAC3BC,cAAA,CAACJ,sBAAI,EAAA;AAACC,MAAAA,QAAQ,EAAE,CAAE;AAAAE,MAAAA,QAAA,EACf,CAAA;AACT;AACA,aAAA,EAAeL,UAAU,CAAA,UAAA,CAAA;AAAY,KACzB,CAAC,eACPM,cAAA,CAACC,+BAAe,EAAA;AAACP,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KAAE,CAAC,eAC3CM,cAAA,CAACE,aAAa,IAAE,CAAC,CAAA;AAAA,GACb,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('source-map-support/register');
|
|
6
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
7
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
|
+
|
|
9
|
+
function ClientFields() {
|
|
10
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
11
|
+
indent: 2,
|
|
12
|
+
newLines: 2,
|
|
13
|
+
children: `@Inject
|
|
14
|
+
WebSocketClientConnection connection;`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.ClientFields = ClientFields;
|
|
19
|
+
//# sourceMappingURL=ClientFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientFields.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/ClientFields.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ClientFields() {\n return (\n <Text indent={2} newLines={2}>\n {`@Inject\nWebSocketClientConnection connection;`}\n </Text>\n );\n}\n"],"names":["ClientFields","_jsx","Text","indent","newLines","children"],"mappings":";;;;;;;;AAEO,SAASA,YAAYA,GAAG;EAC7B,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,MAAM,EAAE,CAAE;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAC1B,CAAA;AACP,qCAAA,CAAA;AAAsC,GAC5B,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('source-map-support/register');
|
|
6
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
7
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
|
+
|
|
9
|
+
function ConnectorFields({
|
|
10
|
+
clientName
|
|
11
|
+
}) {
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
|
+
indent: 2,
|
|
14
|
+
newLines: 2,
|
|
15
|
+
children: `@Inject
|
|
16
|
+
WebSocketConnector<${clientName}> connector;
|
|
17
|
+
`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.ConnectorFields = ConnectorFields;
|
|
22
|
+
//# sourceMappingURL=ConnectorFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorFields.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/ConnectorFields.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ConnectorFields({ clientName }) {\n return (\n <Text indent={2} newLines={2}>\n {`@Inject\nWebSocketConnector<${clientName}> connector;\n`}\n </Text>\n );\n}\n"],"names":["ConnectorFields","clientName","_jsx","Text","indent","newLines","children"],"mappings":";;;;;;;;AAEO,SAASA,eAAeA,CAAC;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;EAC9C,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,MAAM,EAAE,CAAE;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAC1B,CAAA;AACP,mBAAA,EAAqBL,UAAU,CAAA;AAC/B,CAAA;AAAC,GACS,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('source-map-support/register');
|
|
6
|
+
var ClientFields = require('./ClientFields.js');
|
|
7
|
+
var HandleError = require('./HandleError.js');
|
|
8
|
+
var OnClose = require('./OnClose.js');
|
|
9
|
+
var OnOpen = require('./OnOpen.js');
|
|
10
|
+
var OnTextMessageHandler = require('./OnTextMessageHandler.js');
|
|
11
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
12
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
13
|
+
|
|
14
|
+
function EchoWebSocket({
|
|
15
|
+
clientName,
|
|
16
|
+
pathName,
|
|
17
|
+
title,
|
|
18
|
+
operations
|
|
19
|
+
}) {
|
|
20
|
+
const sendOperations = operations.filterBySend();
|
|
21
|
+
if (!pathName) {
|
|
22
|
+
pathName = '/';
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.Text, {
|
|
25
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
26
|
+
newLines: 2,
|
|
27
|
+
children: `@WebSocketClient(path = "${pathName}")
|
|
28
|
+
public class ${clientName}{`
|
|
29
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ClientFields.ClientFields, {}), /*#__PURE__*/jsxRuntime.jsx(OnOpen, {
|
|
30
|
+
title: title
|
|
31
|
+
}), /*#__PURE__*/jsxRuntime.jsx(OnTextMessageHandler, {
|
|
32
|
+
sendOperations: sendOperations
|
|
33
|
+
}), /*#__PURE__*/jsxRuntime.jsx(HandleError, {}), /*#__PURE__*/jsxRuntime.jsx(OnClose, {
|
|
34
|
+
title: title
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.EchoWebSocket = EchoWebSocket;
|
|
40
|
+
//# sourceMappingURL=EchoWebSocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EchoWebSocket.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/EchoWebSocket.js"],"sourcesContent":["import { ClientFields } from './ClientFields.js';\nimport HandleError from './HandleError.js';\nimport OnClose from './OnClose.js';\nimport OnOpen from './OnOpen.js';\nimport OnTextMessageHandler from './OnTextMessageHandler.js';\nimport { Text } from '@asyncapi/generator-react-sdk';\n\nexport function EchoWebSocket({ clientName, pathName, title, operations }) {\n const sendOperations = operations.filterBySend();\n if (!pathName) {\n pathName = '/';\n }\n\n return (\n <Text>\n <Text newLines={2}>\n {`@WebSocketClient(path = \"${pathName}\") \npublic class ${clientName}{`}\n </Text>\n <ClientFields />\n <OnOpen title={title}/>\n <OnTextMessageHandler sendOperations={sendOperations}/>\n <HandleError/>\n <OnClose title={title} />\n </Text>\n );\n}"],"names":["EchoWebSocket","clientName","pathName","title","operations","sendOperations","filterBySend","_jsxs","Text","children","_jsx","newLines","ClientFields","OnOpen","OnTextMessageHandler","HandleError","OnClose"],"mappings":";;;;;;;;;;;;;AAOO,SAASA,aAAaA,CAAC;EAAEC,UAAU;EAAEC,QAAQ;EAAEC,KAAK;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;AACzE,EAAA,MAAMC,cAAc,GAAGD,UAAU,CAACE,YAAY,EAAE,CAAA;EAChD,IAAI,CAACJ,QAAQ,EAAE;AACbA,IAAAA,QAAQ,GAAG,GAAG,CAAA;AAChB,GAAA;EAEA,oBACEK,eAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EAAA,cACHC,cAAA,CAACF,sBAAI,EAAA;AAACG,MAAAA,QAAQ,EAAE,CAAE;MAAAF,QAAA,EACf,4BAA4BP,QAAQ,CAAA;AAC7C,aAAA,EAAeD,UAAU,CAAA,CAAA,CAAA;KACb,CAAC,eACPS,cAAA,CAACE,yBAAY,IAAE,CAAC,eAChBF,cAAA,CAACG,MAAM,EAAA;AAACV,MAAAA,KAAK,EAAEA,KAAAA;AAAM,KAAC,CAAC,eACvBO,cAAA,CAACI,oBAAoB,EAAA;AAACT,MAAAA,cAAc,EAAEA,cAAAA;KAAgB,CAAC,eACvDK,cAAA,CAACK,WAAW,IAAC,CAAC,eACdL,cAAA,CAACM,OAAO,EAAA;AAACb,MAAAA,KAAK,EAAEA,KAAAA;AAAM,KAAE,CAAC,CAAA;AAAA,GACrB,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function HandleError() {
|
|
8
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
9
|
+
newLines: 2,
|
|
10
|
+
indent: 2,
|
|
11
|
+
children: `@OnError
|
|
12
|
+
public void onError(Throwable throwable) {
|
|
13
|
+
Log.error("Websocket connection error: " + throwable.getMessage());
|
|
14
|
+
}
|
|
15
|
+
`
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = HandleError;
|
|
20
|
+
//# sourceMappingURL=HandleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandleError.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/HandleError.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function HandleError() {\n return (\n <Text newLines={2} indent={2}>\n {`@OnError\npublic void onError(Throwable throwable) {\n Log.error(\"Websocket connection error: \" + throwable.getMessage());\n}\n`}\n </Text>\n );\n}\n\n"],"names":["HandleError","_jsx","Text","newLines","indent","children"],"mappings":";;;;;;AAEe,SAASA,WAAWA,GAAG;EACpC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAC1B,CAAA;AACP;AACA;AACA;AACA,CAAA;AAAC,GACS,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function InitConnector() {
|
|
8
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
9
|
+
newLines: 1,
|
|
10
|
+
children: `
|
|
11
|
+
@PostConstruct
|
|
12
|
+
void openAndSendMessagesWithDelay() {
|
|
13
|
+
new Thread(() -> {
|
|
14
|
+
try {
|
|
15
|
+
Log.info("Starting WebSocket connection attempt...");
|
|
16
|
+
WebSocketClientConnection connection = connector.connectAndAwait();
|
|
17
|
+
|
|
18
|
+
// Wait 2 seconds before first message
|
|
19
|
+
Thread.sleep(2000);
|
|
20
|
+
|
|
21
|
+
// Send 5 messages
|
|
22
|
+
for (int i = 1; i <= 5; i++) {
|
|
23
|
+
String msg = "Message #" + i + " from Quarkus";
|
|
24
|
+
connection.sendTextAndAwait(msg);
|
|
25
|
+
Log.info("Sent: " + msg);
|
|
26
|
+
Thread.sleep(5000);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Wait 10 seconds after final message
|
|
30
|
+
Log.info("All messages sent. Waiting 10 seconds before closing...");
|
|
31
|
+
Thread.sleep(10000);
|
|
32
|
+
|
|
33
|
+
connection.closeAndAwait();
|
|
34
|
+
Log.info("Connection closed gracefully.");
|
|
35
|
+
|
|
36
|
+
} catch (Exception e) {
|
|
37
|
+
Log.error("Error during WebSocket communication", e);
|
|
38
|
+
}
|
|
39
|
+
}).start();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = InitConnector;
|
|
47
|
+
//# sourceMappingURL=InitConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitConnector.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/InitConnector.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function InitConnector() {\n return (\n <Text newLines={1}>\n {`\n @PostConstruct\n void openAndSendMessagesWithDelay() {\n new Thread(() -> {\n try {\n Log.info(\"Starting WebSocket connection attempt...\");\n WebSocketClientConnection connection = connector.connectAndAwait();\n\n // Wait 2 seconds before first message\n Thread.sleep(2000);\n\n // Send 5 messages\n for (int i = 1; i <= 5; i++) {\n String msg = \"Message #\" + i + \" from Quarkus\";\n connection.sendTextAndAwait(msg);\n Log.info(\"Sent: \" + msg);\n Thread.sleep(5000);\n }\n\n // Wait 10 seconds after final message\n Log.info(\"All messages sent. Waiting 10 seconds before closing...\");\n Thread.sleep(10000);\n\n connection.closeAndAwait();\n Log.info(\"Connection closed gracefully.\");\n\n } catch (Exception e) {\n Log.error(\"Error during WebSocket communication\", e);\n }\n }).start();\n }\n}\n`}\n </Text>\n );\n}"],"names":["InitConnector","_jsx","Text","newLines","children"],"mappings":";;;;;;AAEe,SAASA,aAAaA,GAAG;EACtC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAAAC,IAAAA,QAAA,EACf,CAAA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAA;AAAC,GACS,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function OnClose({
|
|
8
|
+
title
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
11
|
+
children: `
|
|
12
|
+
@OnClose
|
|
13
|
+
public void onClose(CloseReason reason, WebSocketClientConnection connection) {
|
|
14
|
+
int code = reason.getCode();
|
|
15
|
+
Log.info("Websocket disconnected from ${title} with Close code: " + code);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = OnClose;
|
|
23
|
+
//# sourceMappingURL=OnClose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnClose.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/OnClose.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OnClose({ title }) {\n return (\n <Text>\n {`\n @OnClose\n public void onClose(CloseReason reason, WebSocketClientConnection connection) {\n int code = reason.getCode();\n Log.info(\"Websocket disconnected from ${title} with Close code: \" + code);\n }\n}\n`}\n </Text>\n );\n}"],"names":["OnClose","title","_jsx","Text","children"],"mappings":";;;;;;AAEe,SAASA,OAAOA,CAAC;AAAEC,EAAAA,KAAAA;AAAM,CAAC,EAAE;EACzC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAAAC,IAAAA,QAAA,EACF,CAAA;AACP;AACA;AACA;AACA,4CAAA,EAA8CH,KAAK,CAAA;AACnD;AACA;AACA,CAAA;AAAC,GACS,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function OnOpen({
|
|
8
|
+
title
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
11
|
+
newLines: 1,
|
|
12
|
+
indent: 2,
|
|
13
|
+
children: `
|
|
14
|
+
@OnOpen
|
|
15
|
+
public void onOpen() {
|
|
16
|
+
String broadcastMessage = "Echo called from ${title} server";
|
|
17
|
+
Log.info("Connected to ${title} server");
|
|
18
|
+
Log.info(broadcastMessage);
|
|
19
|
+
}
|
|
20
|
+
`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = OnOpen;
|
|
25
|
+
//# sourceMappingURL=OnOpen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnOpen.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/OnOpen.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OnOpen({ title }) {\n return (\n <Text newLines={1} indent={2}>\n {`\n@OnOpen\npublic void onOpen() {\n String broadcastMessage = \"Echo called from ${title} server\";\n Log.info(\"Connected to ${title} server\");\n Log.info(broadcastMessage);\n}\n`}\n </Text>\n );\n}\n"],"names":["OnOpen","title","_jsx","Text","newLines","indent","children"],"mappings":";;;;;;AAEe,SAASA,MAAMA,CAAC;AAAEC,EAAAA,KAAAA;AAAM,CAAC,EAAE;EACxC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAC1B,CAAA;AACP;AACA;AACA,gDAAA,EAAkDL,KAAK,CAAA;AACvD,2BAAA,EAA6BA,KAAK,CAAA;AAClC;AACA;AACA,CAAA;AAAC,GACS,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function OnTextMessage({
|
|
8
|
+
sendOperations
|
|
9
|
+
}) {
|
|
10
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
14
|
+
children: sendOperations.map(operation => {
|
|
15
|
+
const methodName = operation.id();
|
|
16
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
17
|
+
newLines: 2,
|
|
18
|
+
indent: 2,
|
|
19
|
+
children: `@OnTextMessage
|
|
20
|
+
public void ${methodName}(String message, WebSocketClientConnection connection) {
|
|
21
|
+
Log.info("Received text message: " + message);
|
|
22
|
+
}`
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = OnTextMessage;
|
|
29
|
+
//# sourceMappingURL=OnTextMessageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnTextMessageHandler.js","sources":["../../../../../../../../packages/templates/clients/websocket/java/quarkus/components/OnTextMessageHandler.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OnTextMessage({sendOperations}) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n }\n\n return (\n <>\n {\n sendOperations.map((operation) => {\n const methodName = operation.id(); \n return (\n <Text newLines={2} indent={2}>\n {`@OnTextMessage\npublic void ${methodName}(String message, WebSocketClientConnection connection) {\n Log.info(\"Received text message: \" + message);\n}`}\n </Text>\n );\n })\n }\n </>\n );\n}"],"names":["OnTextMessage","sendOperations","length","_jsx","_Fragment","children","map","operation","methodName","id","Text","newLines","indent"],"mappings":";;;;;;AAEe,SAASA,aAAaA,CAAC;AAACC,EAAAA,cAAAA;AAAc,CAAC,EAAE;EACtD,IAAI,CAACA,cAAc,IAAIA,cAAc,CAACC,MAAM,KAAK,CAAC,EAAE;AAClD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;EAEA,oBACEC,cAAA,CAAAC,mBAAA,EAAA;AAAAC,IAAAA,QAAA,EAEIJ,cAAc,CAACK,GAAG,CAAEC,SAAS,IAAK;AAChC,MAAA,MAAMC,UAAU,GAAGD,SAAS,CAACE,EAAE,EAAE,CAAA;MACjC,oBACEN,cAAA,CAACO,sBAAI,EAAA;AAACC,QAAAA,QAAQ,EAAE,CAAE;AAACC,QAAAA,MAAM,EAAE,CAAE;AAAAP,QAAAA,QAAA,EAC1B,CAAA;AACf,YAAA,EAAcG,UAAU,CAAA;AACxB;AACA,CAAA,CAAA;AAAE,OACgB,CAAC,CAAA;KAEV,CAAA;AAAC,GAEJ,CAAC,CAAA;AAEP;;;;"}
|