{"modulePath":"github.com/RedAFD/code-core","version":"v1.14.0-rc8","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package eventsource\n\n## Types\n\n```go\ntype Event struct {\n\t// Name represents the value of the event: tag in the stream\n\tName string\n\t// Data is either JSONified []byte or interface{} that can be JSONd\n\tData interface{}\n\t// ID represents the ID of an event\n\tID string\n\t// Retry tells the receiver only to attempt to reconnect to the source after this time\n\tRetry time.Duration\n}\n```\nEvent is an eventsource event, not all fields need to be set\n\n```go\nfunc (e *Event) String() string\n```\n\n```go\nfunc (e *Event) WriteTo(w io.Writer) (int64, error)\n```\nWriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.\n\n```go\ntype Manager struct {\n\t// contains filtered or unexported fields\n}\n```\nManager manages the eventsource Messengers\n\n```go\nfunc GetManager() *Manager\n```\nGetManager returns a Manager and initializes one as singleton if there's none yet\n\n```go\nfunc (m *Manager) Init()\n```\nInit starts this eventsource\n\n```go\nfunc (m *Manager) Register(uid int64) \u003c-chan *Event\n```\nRegister message channel\n\n```go\nfunc (m *Manager) Run(ctx context.Context)\n```\nRun runs the manager within a provided context\n\n```go\nfunc (m *Manager) SendMessage(uid int64, message *Event)\n```\nSendMessage sends a message to a particular user\n\n```go\nfunc (m *Manager) SendMessageBlocking(uid int64, message *Event)\n```\nSendMessageBlocking sends a message to a particular user\n\n```go\nfunc (m *Manager) Unregister(uid int64, channel \u003c-chan *Event)\n```\nUnregister message channel\n\n```go\nfunc (m *Manager) UnregisterAll()\n```\nUnregisterAll message channels\n\n```go\ntype Messenger struct {\n\t// contains filtered or unexported fields\n}\n```\nMessenger is a per uid message store\n\n```go\nfunc NewMessenger(uid int64) *Messenger\n```\nNewMessenger creates a messenger for a particular uid\n\n```go\nfunc (m *Messenger) Register() \u003c-chan *Event\n```\nRegister returns a new chan \\[]byte\n\n```go\nfunc (m *Messenger) SendMessage(message *Event)\n```\nSendMessage sends the message to all registered channels\n\n```go\nfunc (m *Messenger) SendMessageBlocking(message *Event)\n```\nSendMessageBlocking sends the message to all registered channels and ensures it gets sent\n\n```go\nfunc (m *Messenger) Unregister(channel \u003c-chan *Event) bool\n```\nUnregister removes the provider chan \\[]byte\n\n```go\nfunc (m *Messenger) UnregisterAll()\n```\nUnregisterAll removes all chan \\[]byte\n\n","path":"github.com/RedAFD/code-core/modules/eventsource","name":"eventsource","synopsis":"","isRedistributable":true}
