feat: raising hand endpoint
This commit is contained in:
@@ -30,6 +30,22 @@ func (r *Room)InitMaps() {
|
||||
}
|
||||
}
|
||||
|
||||
// if you have no hand raised - select any hand
|
||||
// if you are not speaking and have a hand raise - just exchange
|
||||
// if you are speaking - change nothing
|
||||
// if nobody is speaking, set this person as a first speaker
|
||||
func (r *Room) RaiseHand(p PersonId, gesture HandGesture) Room {
|
||||
if (r.CurrentSpeaker == p) {
|
||||
// if person already speaking, should first end speaking
|
||||
return *r
|
||||
}
|
||||
r.ParticipantHands[p] = gesture
|
||||
if r.CurrentSpeaker == PersonId(0) {
|
||||
r.CurrentSpeaker = p
|
||||
}
|
||||
return *r
|
||||
}
|
||||
|
||||
// and how would i organize?
|
||||
// i should have map[HandGesture]ParticipantId as mark. for 'from where to go clockwise if returning a level lover'
|
||||
// now i want methods that for some person raise some hand, so i guess it adds what? to map[ParticipantId]HandGesture
|
||||
@@ -161,6 +177,13 @@ const (
|
||||
Meta
|
||||
)
|
||||
|
||||
func GestureFromInt(num int) (HandGesture, bool) {
|
||||
if (num >= int(ChangeTopic) && num <= int(Meta)) {
|
||||
return HandGesture(num), true
|
||||
}
|
||||
return HandGesture(0), false
|
||||
}
|
||||
|
||||
// String() method to print the name of the days
|
||||
func (g HandGesture) String() string {
|
||||
return [...]string{"Change Topic", "Probing Quesion", "Expand", "Clarifying Quesion", "Meta"}[g]
|
||||
|
||||
@@ -13,6 +13,16 @@ import (
|
||||
|
||||
type PersonId int
|
||||
|
||||
func (p PersonId) MarshalBinary() ([]byte, error) {
|
||||
bytes, err := json.Marshal(p)
|
||||
return bytes, err
|
||||
}
|
||||
|
||||
func (p *PersonId) UnmarshalBinary(data []byte) error {
|
||||
err := json.Unmarshal(data, p)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO move to rooms i guess
|
||||
func RandomPersonId() PersonId {
|
||||
randInt := rand.Int()
|
||||
@@ -81,6 +91,7 @@ func (redisRM RedisRM) Update(ctx context.Context, roomName string, f func(fromR
|
||||
return err
|
||||
}
|
||||
|
||||
savedRoom.InitMaps()
|
||||
room := f(savedRoom)
|
||||
|
||||
_, err = tx.Pipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||
|
||||
Reference in New Issue
Block a user