Enha: sse update on actions
This commit is contained in:
		| @@ -4,6 +4,7 @@ import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"golias/broker" | ||||
| 	"golias/models" | ||||
| 	"golias/utils" | ||||
| 	"strings" | ||||
| @@ -168,6 +169,7 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error) | ||||
| 				return fi, err | ||||
| 			} | ||||
| 			fi.Room.BlueTeam.Mime = fi.State.Username | ||||
| 			fi.Room.BlueTeam.Color = "blue" | ||||
| 			fi.State.Team = "blue" | ||||
| 			fi.State.Role = "mime" | ||||
| 			if fi.Room.RedTeam.Mime == fi.State.Username { | ||||
| @@ -180,6 +182,7 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error) | ||||
| 				return fi, err | ||||
| 			} | ||||
| 			fi.Room.RedTeam.Mime = fi.State.Username | ||||
| 			fi.Room.RedTeam.Color = "red" | ||||
| 			fi.State.Team = "red" | ||||
| 			fi.State.Role = "mime" | ||||
| 			if fi.Room.BlueTeam.Mime == fi.State.Username { | ||||
| @@ -192,10 +195,12 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error) | ||||
| 	} else if role == "guesser" { | ||||
| 		if team == "blue" { | ||||
| 			fi.Room.BlueTeam.Guessers = append(fi.Room.BlueTeam.Guessers, fi.State.Username) | ||||
| 			fi.Room.BlueTeam.Color = "blue" | ||||
| 			fi.State.Team = "blue" | ||||
| 			fi.State.Role = "guesser" | ||||
| 		} else if team == "red" { | ||||
| 			fi.Room.RedTeam.Guessers = append(fi.Room.RedTeam.Guessers, fi.State.Username) | ||||
| 			fi.Room.RedTeam.Color = "red" | ||||
| 			fi.State.Team = "red" | ||||
| 			fi.State.Role = "guesser" | ||||
| 		} else { | ||||
| @@ -232,3 +237,10 @@ func listPublicRooms() []*models.Room { | ||||
| 	} | ||||
| 	return publicRooms | ||||
| } | ||||
|  | ||||
| func notify(event, msg string) { | ||||
| 	Notifier.Notifier <- broker.NotificationEvent{ | ||||
| 		EventName: event, | ||||
| 		Payload:   msg, | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder