Documentation ¶
Index ¶
Constants ¶
View Source
const ( MsgTypeNormal = iota MsgTypeWelcome MsgTypeUserEnter MsgTypeUserLeave MsgTypeError )
Variables ¶
View Source
var Broadcaster = &broadcaster{ users: make(map[string]*User), enteringChannel: make(chan *User), leavingChannel: make(chan *User), messageChannel: make(chan *Message, global.MessageQueueLen), checkUserChannel: make(chan string), checkUserCanEnterChannel: make(chan bool), requestUserChannel: make(chan struct{}), usersChannel: make(chan []*User), }
Broadcaster 广播
View Source
var System = &User{}
System 系统用户,代表是系统主动发送的消息
Functions ¶
func FilterSensitive ¶
FilterSensitive replace sensitive words with **
Types ¶
type Message ¶
type Message struct { User *User `json:"user"` Type int `json:"type"` Content string `json:"content"` MsgTime time.Time `json:"msg_time"` ClientSendTime time.Time `json:"client_send_time"` // @ function Ats []string `json:"ats"` }
Message 消息结构体
func NewMessage ¶
NewMessage gen a new message
type User ¶
type User struct { UID int `json:"uid"` NickName string `json:"nickname"` EnterAt time.Time `json:"enter_at"` Addr string `json:"addr"` MessageChannel chan *Message `json:"-"` Token string `json:"token"` // contains filtered or unexported fields }
User struct
func (*User) CloseMessageChannel ¶
func (u *User) CloseMessageChannel()
CloseMessageChannel 避免 goroutine 泄露
Click to show internal directories.
Click to hide internal directories.