Documentation
¶
Index ¶
Constants ¶
View Source
const (
SYSTEM_CMD_REMOVE_USER = "remove_user"
)
Variables ¶
View Source
var ( // ErrorClose 连接关闭的错误信息 ErrorClose = errors.New("firetower is collapsed") // ErrorBlock block错误信息 ErrorBlock = errors.New("network congestion") )
Functions ¶
This section is empty.
Types ¶
type DefaultCoder ¶
type DefaultCoder[T any] struct{}
func (*DefaultCoder[T]) Decode ¶
func (c *DefaultCoder[T]) Decode(data []byte, fire *FireInfo[T]) error
func (*DefaultCoder[T]) Encode ¶
func (c *DefaultCoder[T]) Encode(msg *FireInfo[T]) []byte
type FireInfo ¶
type FireInfo[T any] struct { Context FireLife `json:"c"` MessageType int `json:"t"` Message TopicMessage[T] `json:"m"` }
FireInfo 接收的消息结构体
func (*FireInfo[T]) GetContext ¶
func (*FireInfo[T]) GetMessage ¶
func (f *FireInfo[T]) GetMessage() TopicMessage[T]
type FireLife ¶
type FireLife struct { ID string `json:"i"` StartTime time.Time `json:"t"` ClientID string `json:"c"` UserID string `json:"u"` Source FireSource `json:"s"` ExtMeta map[string]string `json:"e,omitempty"` }
FireLife 客户端推送消息的结构体
func (*FireLife) Reset ¶
func (f *FireLife) Reset(source FireSource, clientID, userID string)
type FireOperation ¶
type FireOperation uint8
const ( // PublishKey 与前端(客户端约定的推送关键字) PublishOperation FireOperation = 1 SubscribeOperation FireOperation = 2 UnSubscribeOperation FireOperation = 3 // OfflineTopicByUserIdKey 踢除,将用户某个topic踢下线 OfflineTopicByUserIdOperation FireOperation = 4 // OfflineTopicKey 针对某个topic进行踢除 OfflineTopicOperation FireOperation = 5 // OfflineUserKey 将某个用户踢下线 OfflineUserOperation FireOperation = 6 )
func (FireOperation) String ¶
func (o FireOperation) String() string
type FireSource ¶
type FireSource uint8
const ( SourceClient FireSource = 1 SourceLogic FireSource = 2 SourceSystem FireSource = 3 )
func (FireSource) String ¶
func (s FireSource) String() string
type ReadOnlyFire ¶
type ReadOnlyFire[T any] interface { GetContext() FireLife GetMessage() TopicMessage[T] Copy() FireInfo[T] }
type SinglePusher ¶
type SinglePusher[T any] struct { // contains filtered or unexported fields }
func DefaultPusher ¶
func DefaultPusher[T any](b Brazier[T], coder Coder[T], logger Logger) *SinglePusher[T]
func (*SinglePusher[T]) Publish ¶
func (s *SinglePusher[T]) Publish(fire *FireInfo[T]) error
func (*SinglePusher[T]) Receive ¶
func (s *SinglePusher[T]) Receive() chan *FireInfo[T]
type TopicMessage ¶
type TopicMessage[T any] struct { Topic string `json:"topic"` Data T `json:"data,omitempty"` Type FireOperation `json:"type"` }
TopicMessage 话题信息结构体
func (*TopicMessage[T]) Json ¶
func (s *TopicMessage[T]) Json() []byte
type WebSocketMessage ¶
Click to show internal directories.
Click to hide internal directories.