From c7a221e43a404059e9368ae76bea1e7ed242d2cf Mon Sep 17 00:00:00 2001 From: Khuda Dad Nomani Date: Wed, 10 Jan 2024 13:39:04 +0000 Subject: [PATCH] fix the docs --- docs/pages/function-lifecycle-events.md | 8 +++++--- docs/pages/glee-template.md | 10 ++-------- docs/pages/index.md | 7 +++---- docs/pages/installation.md | 7 +++---- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/pages/function-lifecycle-events.md b/docs/pages/function-lifecycle-events.md index d47f8f87b..7e4a1bd25 100644 --- a/docs/pages/function-lifecycle-events.md +++ b/docs/pages/function-lifecycle-events.md @@ -22,12 +22,14 @@ Functions take a single argument, which is the event received from a broker or a |channel|The name of the channel/topic from which the event was read. |serverName|The name of the server/broker from which the event was received. -Functions may return an object to tell Glee what to do next. For instance, the following example greets the user back: +Functions may return an object to tell Glee what to do next. For instance, the following example sends a greeting message to `development` server: ```js /* onHello.js */ export default async function (event) { return { - reply: [{ + send: [{ + server: 'developement', + channel: 'greets', payload: 'Greetings! How is your day going?' }] } @@ -37,7 +39,7 @@ export default async function (event) { |Attribute|Type|Description| |---|---|---| |send|array<[OutboundMessage](#anatomy-of-an-outbound-message)>|A list of outbound messages to send when the processing of the inbound event has finished. All clients subscribed to the given channel/topic will receive the message. -|reply|array<[OutboundMessage](#anatomy-of-an-outbound-message)>|A list of outbound messages to send as a reply when the processing of the inbound event has finished. This is useful when the target of your message is the sender of the inbound event. Note, however, that this only works when you're running Glee as a server. For example, using `reply` when receiving a WebSocket message is fine and the reply will exclusively go to the client that sent the message. However, if you're receiving a message from an MQTT broker, `reply` will work exactly the same way as `send` above, and will send the message to all the clients subscribed to the given channel/topic. + ##### Anatomy of an outbound message |Attribute|Type|Description| |---|---|---| diff --git a/docs/pages/glee-template.md b/docs/pages/glee-template.md index ec0db7a50..8fea93cfc 100644 --- a/docs/pages/glee-template.md +++ b/docs/pages/glee-template.md @@ -24,9 +24,6 @@ operations: action: receive channel: $ref: '#/channels/hello' - reply: - channel: - $ref: "#/channels/hello" SendHello: action: send channel: @@ -73,9 +70,6 @@ operations: action: receive channel: $ref: '#/channels/hello' - reply: - channel: - $ref: "#/channels/hello" sendHello: action: send channel: @@ -84,8 +78,8 @@ operations: The channels section defines the communication channels available in the API. In this case, there's a channel named "hello". This channel supports both sending and receiving. -The `receive` action indicates that messages received on the `hello` channel should follow the structure defined in the hello message component. Under this action, `reply` which is in a request-reply operation, contains the payload on `onHello.js` function. -The `send` action specifies that the operation with ID `sendHello` is used for sending messages to the `hello` channel. The message structure is referenced from the hello message component. +The `receive` action indicates that messages received on the `hello` channel should follow the structure defined in the hello message component. +The `send` action specifies that the operation with ID `sendHello` is used for sending messages to the `hello` channel. The message structure is referenced from the hello message component. The message payload is going to be validated against the `sendHello` operation message schemas. Next is the `payload` property under `hello` message component which is used to understand how the event should look like when publishing to that channel: diff --git a/docs/pages/index.md b/docs/pages/index.md index ef5638eec..bc1b1d540 100644 --- a/docs/pages/index.md +++ b/docs/pages/index.md @@ -82,9 +82,6 @@ operations: action: receive channel: $ref: '#/channels/greet' - reply: - channel: - $ref: '#/channels/greet' sendGreet: action: send channel: @@ -127,8 +124,10 @@ export default async function (event) { response = `Good Evening ${name}` } return { - reply: [ + send: [ { + server: "websockets", + channel: "greet" payload: response, }, ], diff --git a/docs/pages/installation.md b/docs/pages/installation.md index b3d587e39..e06de1bf7 100644 --- a/docs/pages/installation.md +++ b/docs/pages/installation.md @@ -102,9 +102,6 @@ operations: action: receive channel: $ref: '#/channels/hello' - reply: - channel: - $ref: "#/channels/hello" SendHello: action: send channel: @@ -121,7 +118,9 @@ Create an operation function `onHello.js` inside `myapp/functions`: ```js export default async function (event) { return { - reply: [{ + send: [{ + server: "websockets", + channel: "hello", payload: `Hello from Glee! You said: "${event.payload}".` }] }