Documentation ¶
Index ¶
- Constants
- Variables
- func CheckErr(err error)
- func Error(msg string) error
- func FlushLog()
- func GenerateUnixNanoId() string
- func GetConfig(configFile string, sec string) (map[string]string, error)
- func JsonDecode(jsonStr string) interface{}
- func JsonEncode(nodes interface{}) string
- func LoadConfig(section string) map[string]string
- func Log(level LogLevel, a ...interface{})
- func Logf(level LogLevel, format string, a ...interface{})
- func SendStats(cmdCode int) (replyChan chan string)
- func SetGenerateUid(f func() string)
- func SetGetConnCallback(f func(string, *Room))
- func SetLoseConnCallback(f func(string, *Room))
- func SetRequestHandler(f func(map[string]interface{}, string, *Room))
- func Start()
- func StatsReport() string
- func UptimeFormat(secs uint32, section int) string
- func WsServer(ws *websocket.Conn)
- type Box
- type ConfigType
- type CoordNode
- type LogLevel
- type MapType
- func (this *MapType) AddCoord(key string, x, y int)
- func (this *MapType) AddCoordNode(key string, coordNode *CoordNode)
- func (this *MapType) DeleteCoordNode(key string) bool
- func (this *MapType) Encode(x, y int) (string, *Box)
- func (this *MapType) GetAllCoordNodes() map[string]*CoordNode
- func (this *MapType) GetCoordNode(key string) (*CoordNode, bool)
- func (this *MapType) GetNeighbors(x, y int) []string
- func (this *MapType) NewCoordNode(x, y int) *CoordNode
- func (this *MapType) QueryNearestSquare(x, y int) []string
- func (this *MapType) QueryNearestSquareFromKey(key string) []string
- func (this *MapType) UpdateCoord(key string, newx, newy int) bool
- func (this *MapType) UpdateCoordNode(key string, coordNode *CoordNode) bool
- type Room
- func (room *Room) Broadcast(replyBody map[string]interface{}) error
- func (room *Room) ChangeConn(index int, con *websocket.Conn)
- func (room *Room) ExistUser(uid string) (bool, int)
- func (room *Room) NewUser(ws *websocket.Conn, uid string) string
- func (room *Room) Push(user User, replyBody map[string]interface{}) error
- func (room *Room) PushByUid(uid string, replyBody map[string]interface{}) error
- func (room *Room) PushUserCount(event string, uid string)
- func (room *Room) RemoveUser(uid string)
- type ServerStats
- type ServiceError
- type User
- type UserList
Constants ¶
View Source
const ( WsParamTypeGet = 1 WsParamTypeCookie = 2 )
View Source
const ( LogLevelDebug = iota LogLevelInfo LogLevelNotice LogLevelWarning LogLevelError )
defined log levels
View Source
const ( StatsCmdNewUser = iota StatsCmdLostUser StatsCmdNewRoom StatsCmdCloseRoom StatsCmdReport )
View Source
const ( WsBroadTypeAll = 1 WsBroadTypeRoom = 2 WsBroadTypeMap = 3 )
View Source
const (
BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz"
)
map 64800
View Source
const (
Version = "0.1.0"
)
Variables ¶
View Source
var GenerateUid func() string
View Source
var GetConnCallback func(string, *Room)
View Source
var HandleRequest func(map[string]interface{}, string, *Room)
View Source
var LoseConnCallback func(string, *Room)
Functions ¶
func GenerateUnixNanoId ¶
func GenerateUnixNanoId() string
func JsonDecode ¶
func JsonDecode(jsonStr string) interface{}
func JsonEncode ¶
func JsonEncode(nodes interface{}) string
func LoadConfig ¶
func SetGenerateUid ¶
func SetGenerateUid(f func() string)
func SetGetConnCallback ¶
func SetLoseConnCallback ¶
func SetRequestHandler ¶
func StatsReport ¶
func StatsReport() string
func UptimeFormat ¶
Types ¶
type ConfigType ¶
type MapType ¶
func (*MapType) AddCoordNode ¶
增加key的坐标节点
func (*MapType) GetAllCoordNodes ¶
func (*MapType) GetCoordNode ¶
得到key的坐标节点
func (*MapType) GetNeighbors ¶
func (*MapType) NewCoordNode ¶
func (*MapType) QueryNearestSquare ¶
查找(x, y)附近(九宫格内)的节点,返回它们的key
func (*MapType) QueryNearestSquareFromKey ¶
查找key附近(九宫格内)的节点,返回他们的key
type ServerStats ¶
type ServerStats struct { UserCurrent uint UserPeak uint RoomCurrent uint RoomPeak uint Version string StartTime time.Time }
func (*ServerStats) HandleCommand ¶
func (stats *ServerStats) HandleCommand(cmd statsCmd) error
func (*ServerStats) Report ¶
func (stats *ServerStats) Report() string
type ServiceError ¶
type ServiceError struct {
Msg string
}
func (*ServiceError) Error ¶
func (e *ServiceError) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.