예제 #1
0
func main() {
	defer func() {
		if x := recover(); x != nil {
			ERR("caught panic in main()", x)
		}
	}()

	// 获取监听端口
	getPort()

	//启动
	global.Startup(global.ServerName, "game_log", nil)

	//连接TransferServer
	err := transferProxy.InitClient(cfg.GetValue("transfer_ip"), cfg.GetValue("transfer_port"))
	checkError(err)

	//连接WorldServer
	worldProxyErr := worldProxy.InitClient(cfg.GetValue("world_ip"), cfg.GetValue("world_port"))
	checkError(worldProxyErr)

	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
	checkError(redisProxyErr)

	//连接LogServer
	logProxyErr := logProxy.InitClient(cfg.GetValue("log_ip"), cfg.GetValue("log_port"))
	checkError(logProxyErr)

	//保持进程
	global.Run()
}
예제 #2
0
func startLocalServer() {
	//连接DB
	db.Init()

	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"))
	checkError(redisProxyErr)

	listener, err := link.Serve("tcp", "0.0.0.0:"+local_port, packet.New(
		binary.SplitByUint32BE, 1024, 1024, 1024,
	))
	checkError(err)

	listener.Serve(func(session *link.Session) {
		session.AddCloseCallback(session, func() {
			session.Close()
		})
		global.AddSession(session)

		var msg packet.RAW
		for {
			if err := session.Receive(&msg); err != nil {
				break
			}
			module.ReceiveMessage(session, msg)
		}
	})
}
예제 #3
0
func main() {
	defer func() {
		if x := recover(); x != nil {
			ERR("caught panic in main()", x)
		}
	}()

	// 获取监听端口
	getPort()

	//启动
	global.Startup(global.ServerName, "login_log", nil)

	//连接TransferServer
	err := transferProxy.InitClient(cfg.GetValue("transfer_ip"), cfg.GetValue("transfer_port"))
	checkError(err)

	//连接DB
	dbProxyErr := dbProxy.InitClient(cfg.GetValue("db_ip"), cfg.GetValue("db_port"))
	checkError(dbProxyErr)

	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"))
	checkError(redisProxyErr)

	//保持进程
	global.Run()
}
예제 #4
0
func main() {
	defer func() {
		if x := recover(); x != nil {
			ERR("caught panic in main()", x)
		}
	}()

	// 获取监听端口
	getPort()

	//启动
	global.Startup(global.ServerName, "world_log", nil)

	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
	checkError(redisProxyErr)

	//连接LogServer
	logProxyErr := logProxy.InitClient(cfg.GetValue("log_ip"), cfg.GetValue("log_port"))
	checkError(logProxyErr)

	//启动WorldServer
	worldProxyErr := worldProxy.InitServer(world_port)
	checkError(worldProxyErr)

	//开启下线用户处理
	module.User.StartDealOfflineUser()

	//保持进程
	global.Run()
}
예제 #5
0
func startLocalServer() {
	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
	checkError(redisProxyErr)

	//开启DB
	db.Init()

	//开启同步DB数据到数据库
	dbProxy.StartSysDB()

	//开启客户端监听
	addr := "0.0.0.0:" + local_port
	err := global.Listener("tcp", addr, global.PackCodecType_UnSafe,
		func(session *link.Session) {
			global.AddSession(session)
		},
		gameProxy.MsgDispatch,
	)
	checkError(err)
}
예제 #6
0
func main() {
	defer func() {
		if x := recover(); x != nil {
			ERR("caught panic in main()", x)
		}
	}()

	// 获取监听端口
	getPort()

	//启动
	global.Startup(global.ServerName, "db_log", stopDBServer)

	//连接Redis
	redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
	checkError(redisProxyErr)

	//开启DBServer监听
	err := dbProxy.InitServer(db_port)
	checkError(err)

	//保持进程
	global.Run()
}