func (r *Runner) sendMessageForGame(ctx context.Context, m message.Message) {
	if m.Game == nil {
		r.log.Printf("no 'game' to send game message for in %v", m)
		return
	}
	socketAddrs, ok := r.playerSockets[m.PlayerName]
	if !ok {
		r.log.Printf("could not send game message to %v, socket addrs not found - message: (%v)", m.PlayerName, m)
		return
	}
	var addr message.Addr
	switch m.Type {
	case message.JoinGame:
		addr = m.Addr
	case message.LeaveGame:
		defer r.leaveGame(ctx, m)
		if len(m.Addr) != 0 {
			addr = m.Addr
			break
		}
		fallthrough
	default:
		games, gOk := r.playerGames[m.PlayerName]
		if !gOk {
			return // don't worry if player not connected
		}
		var aOk bool
		addr, aOk = games[m.Game.ID]
		if !aOk {
			return // don't worry if player not observing game
		}
	}
	socketIn, ok := socketAddrs[addr]
	if !ok {
		r.log.Printf("could not send game message to %v at %v - message: (%v)", m.PlayerName, addr, m)
		return
	}
	switch m.Type {
	case message.JoinGame:
		r.joinGame(ctx, m, socketIn)
	default:
		message.Send(m, socketIn, r.Debug, r.log)
	}
}
// sendMessageForGame sends the game message to the player at the address, if possible.
sendMessageForGame sends the game message to the player at the address, if possible.
// sendMessageForGame sends the game message to the player at the address if possible .
func (r *Runner) sendMessageForGame(ctx context.Context, m message.Message) {
	if m.Game == nil {
		r.log.Printf("no 'game' to send game message for in %v", m)
		return
	}
	socketAddrs, ok := r.playerSockets[m.PlayerName]
	if !ok {
		r.log.Printf("could not send game message to %v, socket addrs not found - message: (%v)", m.PlayerName, m)
		return
	}
	var addr message.Addr
	switch m.Type {
	case message.JoinGame:
		addr = m.Addr
	case message.LeaveGame:
		defer r.leaveGame(ctx, m)
		if len(m.Addr) != 0 {
			addr = m.Addr
			break
		}
		fallthrough
	default:
		games, gOk := r.playerGames[m.PlayerName]
		if !gOk {
			return 
		}
		var aOk bool
		addr, aOk = games[m.Game.ID]
		if !aOk {
			return 
		}
	}
	socketIn, ok := socketAddrs[addr]
	if !ok {
		r.log.Printf("could not send game message to %v at %v - message: (%v)", m.PlayerName, addr, m)
		return
	}
	switch m.Type {
	case message.JoinGame:
		r.joinGame(ctx, m, socketIn)
	default:
		message.Send(m, socketIn, r.Debug, r.log)
	}
}
func ( r * Runner ) sendMessageForGame ( ctx context . Context , m message . Message ) { if m . Game == nil { r . log . Printf ( " " , m ) return } socketAddrs , ok := r . playerSockets [ m . PlayerName ] if ! ok { r . log . Printf ( " " , m . PlayerName , m ) return } var addr message . Addr switch m . Type { case message . JoinGame : addr = m . Addr case message . LeaveGame : defer r . leaveGame ( ctx , m ) if len ( m . Addr ) != 0 { addr = m . Addr break } fallthrough default : games , gOk := r . playerGames [ m . PlayerName ] if ! gOk { return } var aOk bool addr , aOk = games [ m . Game . ID ] if ! aOk { return } } socketIn , ok := socketAddrs [ addr ] if ! ok { r . log . Printf ( " " , m . PlayerName , addr , m ) return } switch m . Type { case message . JoinGame : r . joinGame ( ctx , m , socketIn ) default : message . Send ( m , socketIn , r . Debug , r . log ) } }
sendMessageForGame sends the game message to the player at the address, if possible.
sendMessageForGame sends the game message to the player at the address if possible .
// don't worry if player not connected // don't worry if player not observing game