Documentation ¶
Index ¶
Constants ¶
View Source
const ( ConstHeader = "FireHeader" ConstHeaderLength = 10 ConstIntLength = 4 // int转byte长度为4 ConstSplitSpace = " " ConstNewLine = '\n' )
协议中用到的常量
View Source
const ( // PublishKey 与前端(客户端约定的推送关键字) PublishKey = "publish" // OfflineTopicByUserIdKey 踢除,将用户某个topic踢下线 OfflineTopicByUserIdKey = "offline_topic_by_userid" // OfflineTopicKey 针对某个topic进行踢除 OfflineTopicKey = "offline_topic" // OfflineUserKey 将某个用户踢下线 OfflineUserKey = "offline_user" )
Variables ¶
View Source
var ( // ErrorClose 连接关闭的错误信息 ErrorClose = errors.New("firetower is collapsed") // ErrorBlock block错误信息 ErrorBlock = errors.New("network congestion") )
View Source
var ( // LogLevel 日志打印的级别 LogLevel = "INFO" // DefaultWriter 正常日志写入的地方 DefaultWriter io.Writer = os.Stdout // DefaultErrorWriter 错误日志写入的地方 DefaultErrorWriter io.Writer = os.Stderr // SendLogger 消息相关的日志处理方法 SendLogger func(s *SendMessage, types, info string) // Green 绿色 Green = string([]byte{27, 91, 57, 55, 59, 52, 50, 109}) // White 白色 White = string([]byte{27, 91, 57, 48, 59, 52, 55, 109}) // Yellow 黄色 Yellow = string([]byte{27, 91, 57, 55, 59, 52, 51, 109}) // Red 红色 Red = string([]byte{27, 91, 57, 55, 59, 52, 49, 109}) // Blue 蓝色 Blue = string([]byte{27, 91, 57, 55, 59, 52, 52, 109}) // Magenta 品红 Magenta = string([]byte{27, 91, 57, 55, 59, 52, 53, 109}) // Cyan 青色 Cyan = string([]byte{27, 91, 57, 55, 59, 52, 54, 109}) // Reset 重置日志颜色 Reset = string([]byte{27, 91, 48, 109}) )
Functions ¶
Types ¶
type PushMessage ¶
type PushMessage struct { MessageId string `json:"message_id"` Source string `json:"source"` Topic string `json:"topic"` Data []byte `json:"data"` Type string `json:"type"` }
PushMessage 推送消息结构体
type SendMessage ¶
type SendMessage struct { Context *sendLife Type string `json:"type"` MessageType int Data json.RawMessage `json:"data"` Topic string }
SendMessage 发送的消息结构体 发送不用限制用户消息内容的格式
func GetSendMessage ¶
func GetSendMessage(id, source string) *SendMessage
GetSendMessage 创建一条发送记录 id 记录消息id source 记录这条信息是用户推送还是平台推送 user | platform
func (*SendMessage) Panic ¶
func (s *SendMessage) Panic(info string)
Panic 记录一个Panic错误日志并回收SendMessage对象
Click to show internal directories.
Click to hide internal directories.