Send own player object
This commit is contained in:
parent
c0c82f3677
commit
5b022e17fa
@ -96,6 +96,14 @@ func (m *Match) MatchJoin(ctx context.Context, logger runtime.Logger, db *sql.DB
|
||||
Presence: precense,
|
||||
}
|
||||
|
||||
if jsonObj, err := player.GetPosJSON(); err != nil {
|
||||
logger.Error(err.Error())
|
||||
} else {
|
||||
if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, player.Presence, true); sendErr != nil {
|
||||
logger.Error(sendErr.Error())
|
||||
}
|
||||
}
|
||||
|
||||
mState.players[precense.GetUserId()] = player
|
||||
|
||||
// Get intial tile data around player
|
||||
@ -108,12 +116,12 @@ func (m *Match) MatchJoin(ctx context.Context, logger runtime.Logger, db *sql.DB
|
||||
logger.Error(sendErr.Error())
|
||||
}
|
||||
}
|
||||
for _, player := range mState.players {
|
||||
for _, otherPlayer := range mState.players {
|
||||
// Broadcast player data to client
|
||||
if jsonObj, err := player.GetPosJSON(); err != nil {
|
||||
if jsonObj, err := otherPlayer.GetPosJSON(); err != nil {
|
||||
logger.Error(err.Error())
|
||||
} else {
|
||||
if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, player.Presence, true); sendErr != nil {
|
||||
if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, otherPlayer.Presence, true); sendErr != nil {
|
||||
logger.Error(sendErr.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user