Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kernel API for WebSocket message broadcast #9031

Merged
merged 6 commits into from
Aug 23, 2023

Conversation

Zuoqiu-Yingyi
Copy link
Contributor

@Zuoqiu-Yingyi Zuoqiu-Yingyi commented Aug 23, 2023

  • Please commit to the dev branch
  • For contributing new features, please supplement and improve the corresponding user guide documents
  • For bug fixes, please describe the problem and solution via code comments
  • For text improvements (such as typos and wording adjustments), please submit directly

Add APIs for message broadcast

Tested on Windows 11

  • /ws/broadcast: WebSocket
    • Push broadcast messages
    • Receive broadcast messages
    • query params
      • channel: broadcast channel name
    • example
      • ws://127.0.0.1:6806/ws/broadcast?channel=your-channel-name
  • /api/broadcast/channels: GET request
    • Get all channels' info
    • response body
      • {
            "code": 0,
            "msg": "",
            "data": {
                "channels": [
                    {
                        "name": "test-channel",
                        "count": 1
                    }
                ]
            }
        }
  • /api/broadcast/postMessage: POST request
    • Push broadcast messages
    • request body
      • {
            "channel": "your-channel-name",
            "message": "your-message-content"
        }
        • channel: the name of channel
        • message: the message will be broadcast
    • response body
      • {
            "code": 0,
            "msg": "",
            "data": {
                "channel": {
                    "name": "your-channel-name",
                    "count": 1
                }
            }
        }
        • data.channel.count: the count of channel listener
      • {
            "code": -1,
            "msg": "broadcast channel [your-channel-name] not found",
            "data": null
        }
      • {
            "code": -2,
            "msg": "broadcast message failed: ...",
            "data": null
        }
  • /api/broadcast/getChannelInfo: POST request
    • get the info of a channel
    • request body
      • {
            "name": "your-channel-name"
        }
        • name: the name of channel
    • response body
      • {
            "code": 0,
            "msg": "",
            "data": {
                "channel": {
                    "name": "your-channel-name",
                    "count": 1
                }
            }
        }
        • data.channel.name: the name of channel
        • data.channel.count: the count of channel listener
      • {
            "code": -1,
            "msg": "broadcast channel [your-channel-name] not found",
            "data": null
        }

@88250 88250 changed the title Add APIs for message broadcast Add Kernel API for message broadcast Aug 23, 2023
@88250 88250 changed the title Add Kernel API for message broadcast Add Kernel API for WebSocket message broadcast Aug 23, 2023
@88250 88250 merged commit 2f75010 into siyuan-note:dev Aug 23, 2023
@88250 88250 added this to the 2.10.2 milestone Aug 23, 2023
@Zuoqiu-Yingyi Zuoqiu-Yingyi deleted the feat/broadcast branch August 23, 2023 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants