예제 #1
0
// 初始化全局变量
func init_global() {

	global.SumConnections = 0
	global.Qps = 0
	/*
		//worker_nbrs, _ := global.ConfigJson.GetInt64("hub", "number")
		//log.Error("worker_nbrs:", worker_nbrs)
		tmp := int(worker_nbrs)
		var i int

		for i = 1; i <= tmp; i++ {
			global.WorkerNbrs = append(global.WorkerNbrs, fmt.Sprintf("%d", i))

		}
	*/
	// 先在global声明,再使用make函数创建一个非nil的map,nil map不能赋值
	global.Channels = make(map[string]string)

	// global.RpcChannels  =  make(map[string] *z_type.ChannelRpcType )

	global.SyncUserConns = syncmap.New()
	global.SyncUserSessions = syncmap.New()
	global.SyncUserWebsocketConns = syncmap.New()
	global.SyncUserJoinedChannels = syncmap.New()
	global.SyncCrons = syncmap.New()

	global.PackSplitType = `bufferio`

	hub.RedisInit()

	hub.LoadSessionFromRedis()

}
예제 #2
0
파일: area.go 프로젝트: weichaoduo/zeromore
// 创建一个RPC的场景
func CreateChannel(id string, name string) {

	log.Info(id, name)
	global.RpcChannels = append(global.RpcChannels, id)
	global.SyncRpcChannelConns = append(global.SyncRpcChannelConns, syncmap.New())
	global.SyncRpcChannelWsConns = append(global.SyncRpcChannelWsConns, syncmap.New())
	fmt.Println(global.RpcChannels)

}