示例#1
0
文件: server.go 项目: brendonh/gambit
func BuildServer(dbpath string) *GambitServer {
	var services = goservice.NewServiceCollection()

	var server = goservice.NewServer(services, goservice.BasicSessionCreator)

	var websocketEndpoint = goservice.NewWebsocketEndpoint(":4567", server)
	websocketEndpoint.Handler = GameMessageHandler
	server.AddEndpoint(websocketEndpoint)

	return &GambitServer{
		*server,
		loge.NewLogeDB(loge.NewLevelDBStore(dbpath)),
	}
}
示例#2
0
文件: sandbox.go 项目: brendonh/drift
func buildServer() *server.DriftServer {
	var db = loge.NewLogeDB(loge.NewLevelDBStore("data/sandbox"))

	db.CreateType(loge.NewTypeDef("sector", 1, &sectors.Sector{}))
	db.CreateType(loge.NewTypeDef("account", 1, &accounts.Account{}))
	db.CreateType(loge.NewTypeDef("ship", 1, &ships.Ship{}))

	var locDef = loge.NewTypeDef("shiplocation", 1, &simulation.PoweredBody{})
	locDef.Links = loge.LinkSpec{"sector": "sector"}
	db.CreateType(locDef)

	serviceCollection := goservice.NewServiceCollection()
	serviceCollection.AddService(services.GetAccountService())
	serviceCollection.AddService(services.GetSectorService())
	serviceCollection.AddService(services.GetShipService())
	serviceCollection.AddService(loge.GetService())

	return server.NewDriftServer(db, serviceCollection)
}