本文整理汇总了Golang中pkg/config.CherryRooms.GetRooms方法的典型用法代码示例。如果您正苦于以下问题:Golang CherryRooms.GetRooms方法的具体用法?Golang CherryRooms.GetRooms怎么用?Golang CherryRooms.GetRooms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pkg/config.CherryRooms
的用法示例。
在下文中一共展示了CherryRooms.GetRooms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PostFindHandle
// PostFindHandle implements the handle for the find document (POST).
func PostFindHandle(newConn net.Conn, roomName, httpPayload string, rooms *config.CherryRooms, preprocessor *html.Preprocessor) {
var userData map[string]string
userData = rawhttp.GetFieldsFromPost(httpPayload)
var replyBuffer []byte
if _, posted := userData["user"]; !posted {
replyBuffer = rawhttp.MakeReplyBuffer(html.GetBadAssErrorData(), 404, true)
} else {
var result string
result = preprocessor.ExpandData(roomName, rooms.GetFindResultsHeadTemplate(roomName))
listing := rooms.GetFindResultsBodyTemplate(roomName)
availRooms := rooms.GetRooms()
user := strings.ToUpper(userData["user"])
if len(user) > 0 {
for _, r := range availRooms {
users := rooms.GetRoomUsers(r)
preprocessor.SetDataValue("{{.find-result-users-total}}", rooms.GetUsersTotal(r))
preprocessor.SetDataValue("{{.find-result-room-name}}", r)
for _, u := range users {
if strings.HasPrefix(strings.ToUpper(u), user) {
preprocessor.SetDataValue("{{.find-result-user}}", u)
result += preprocessor.ExpandData(roomName, listing)
}
}
}
}
result += preprocessor.ExpandData(roomName, rooms.GetFindResultsTailTemplate(roomName))
replyBuffer = rawhttp.MakeReplyBuffer(result, 200, true)
}
newConn.Write(replyBuffer)
newConn.Close()
}
示例2: openRooms
func openRooms(configPath string) {
var cherryRooms *config.CherryRooms
var err *parser.CherryFileError
cherryRooms, err = parser.ParseCherryFile(configPath)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
} else {
rooms := cherryRooms.GetRooms()
for _, r := range rooms {
go messageplexer.RoomMessagePlexer(r, cherryRooms)
go peer(r, cherryRooms)
}
}
sigintWatchdog := make(chan os.Signal, 1)
signal.Notify(sigintWatchdog, os.Interrupt)
signal.Notify(sigintWatchdog, syscall.SIGINT|syscall.SIGTERM)
<-sigintWatchdog
cleanup()
}