Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weaming/hub
Message hub. Export websocket and HTTP API.
https://github.com/weaming/hub
asyncapi hub message message-driven websocket
Last synced: 3 months ago
JSON representation
Message hub. Export websocket and HTTP API.
- Host: GitHub
- URL: https://github.com/weaming/hub
- Owner: weaming
- Created: 2019-06-13T04:07:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T02:25:25.000Z (almost 2 years ago)
- Last Synced: 2024-07-29T16:59:23.792Z (6 months ago)
- Topics: asyncapi, hub, message, message-driven, websocket
- Language: Go
- Homepage: https://hub.drink.cafe
- Size: 5.14 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hub
* The global `Hub` has many `Topic`s.
* Every `Topic`has many subscribers and publisher, they are websocket connections.
* One websocket connection will receive/publish messages from/to other subscribers.
* `Hub` will publish `Message` to `Topic`.
* `Topic` will send `Message` to all subscribers under it.
* One subscriber maybe receive same messge for more than one times.
* Every subscriber will subscribe the "global" `Topic`.## Core structures
```go
const GlobalTopicID = "global"// types of internal messages
const (
MTPlain string = "PLAIN"
MTMarkdown string = "MARKDOWN"
MTMarkdownV2 string = "MARKDOWNV2"
MTJSON string = "JSON"
MTHTML string = "HTML"
MTPhoto string = "PHOTO"
MTVideo string = "VIDEO"
)// types of websocket messages
const (
MTFeedback string = "FEEDBACK" // used for async event feedback
MTResponse string = "RESPONSE" // used for message response
MTMessage string = "MESSAGE" // used for publish messages
)type RawMessage struct {
Type string `json:"type"` // required
Data string `json:"data"` // required, string or base64 of bytes
Caption string `json:"caption"` // optional
}// http client message
type PubMessage struct {
Type string `json:"type"` // required
Data string `json:"data"` // required, string or base64 of bytes
Caption string `json:"caption"` // required
ExtendedData []RawMessage `json:"extended_data"` // optional, string or base64 of bytes, for sending multiple photos
}
```