本文整理汇总了Golang中pkg/config.CherryRooms.DequeueMessage方法的典型用法代码示例。如果您正苦于以下问题:Golang CherryRooms.DequeueMessage方法的具体用法?Golang CherryRooms.DequeueMessage怎么用?Golang CherryRooms.DequeueMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pkg/config.CherryRooms
的用法示例。
在下文中一共展示了CherryRooms.DequeueMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RoomMessagePlexer
// RoomMessagePlexer performs all message delivering stuff.
func RoomMessagePlexer(roomName string, rooms *config.CherryRooms) {
preprocessor := html.NewHTMLPreprocessor(rooms)
var allUsers = rooms.GetAllUsersAlias(roomName)
for {
runtime.Gosched()
currMessage := rooms.GetNextMessage(roomName)
if len(currMessage.Say) == 0 && len(currMessage.Image) == 0 /*&& len(currMessage.Sound) == 0*/ {
continue
}
var actionTemplate string
if rooms.HasAction(roomName, currMessage.Action) {
actionTemplate = rooms.GetRoomActionTemplate(roomName, currMessage.Action)
}
if len(actionTemplate) == 0 {
actionTemplate = "<p>({{.hour}}:{{.minute}}:{{.second}}) <b>{{.message-colored-user}}</b>: {{.message-says}}" // INFO(Santiago): A very basic action template.
}
message := preprocessor.ExpandData(roomName, actionTemplate)
if currMessage.Priv != "1" {
rooms.AddPublicMessage(roomName, message)
}
preprocessor.SetDataValue("{{.current-formatted-message}}", message)
messageHighlighted := preprocessor.ExpandData(roomName, rooms.GetHighlightTemplate(roomName))
preprocessor.UnsetDataValue("{{.current-formatted-message}}")
users := rooms.GetRoomUsers(roomName)
for _, user := range users {
if currMessage.Priv == "1" &&
user != currMessage.From &&
user != currMessage.To &&
currMessage.To != allUsers {
continue
}
if rooms.IsIgnored(user, currMessage.From, roomName) {
continue
}
var messageBuffer []byte
if user == currMessage.From ||
user == currMessage.To {
messageBuffer = []byte(messageHighlighted)
} else {
messageBuffer = []byte(message)
}
var conn net.Conn
conn = rooms.GetUserConnection(roomName, user)
if conn == nil {
continue
}
_, e := conn.Write(messageBuffer)
if e != nil {
rooms.EnqueueMessage(roomName, user, "", "", "", rooms.GetExitMessage(roomName), "")
rooms.RemoveUser(roomName, user)
}
}
rooms.DequeueMessage(roomName)
}
}