- The global
Hub
has manyTopic
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 publishMessage
toTopic
.Topic
will sendMessage
to all subscribers under it.- One subscriber maybe receive same messge for more than one times.
- Every subscriber will subscribe the "global"
Topic
.
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
}