예제 #1
0
파일: handler.go 프로젝트: Emudofus/gofus
func HandleClientDisconnection(ctx frontend.Service, client frontend.Client) {
	log.Printf("[frontend-net-client-%04d] DCONN", client.Id())

	if client.UserInfos() != nil {
		ctx.Backend().NotifyUserConnection(client.UserInfos().Id, false)
	}
}
예제 #2
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_create_player(ctx frontend.Service, client frontend.Client, m *msg.CreatePlayerReq) {
	player := ctx.Players().NewPlayer(uint(client.UserInfos().Id), m.Name, m.Breed, m.Gender, m.Colors.First, m.Colors.Second, m.Colors.Third)

	if inserted, success := ctx.Players().Persist(player); inserted && success {
		client_send_player_list(ctx, client)
	} else {
		client.Send(&msg.CreatePlayerErrorResp{})
	}
}
예제 #3
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_player_selection(ctx frontend.Service, client frontend.Client, m *msg.PlayerSelectionReq) {
	player, ok := ctx.Players().GetById(m.PlayerId)
	if !ok {
		client.CloseWith(&msg.PlayerSelectionErrorResp{})
		return
	}

	client.SetPlayer(player)
	client.Send(&msg.PlayerSelectionResp{player})
}
예제 #4
0
파일: realm.go 프로젝트: Emudofus/gofus
func client_send_player_list(ctx frontend.Service, client frontend.Client) {
	var players []*db.Player
	var ok bool
	if players, ok = ctx.Players().GetByOwnerId(uint(client.UserInfos().Id)); !ok {
		players = make([]*db.Player, 0, 0)
	}

	client.Send(&msg.PlayersResp{
		ServerId:        ctx.Config().ServerId,
		SubscriptionEnd: client.UserInfos().SubscriptionEnd,
		Players:         players,
	})
}
예제 #5
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_login(ctx frontend.Service, client frontend.Client, m *msg.RealmLoginReq) {
	if infos, ok := ctx.Backend().GetUserInfos(m.Ticket); ok {
		client.SetUserInfos(*infos)
		ctx.Backend().NotifyUserConnection(infos.Id, true)

		client.Send(&msg.RealmLoginSuccess{ctx.Config().CommunityId})
	} else {
		client.CloseWith(&msg.RealmLoginError{})
	}
}
예제 #6
0
파일: realm.go 프로젝트: Emudofus/gofus
func handle_client_regional_version(ctx frontend.Service, client frontend.Client, m *msg.RegionalVersionReq) {
	client.Send(&msg.RegionalVersionResp{ctx.Config().CommunityId})
}