Beispiel #1
0
// Leave the room as a user, will announce. Mostly used during setup.
func (r *Room) Leave(u message.Identifier) error {
	err := r.members.Remove(u)
	if err != nil {
		return err
	}
	s := fmt.Sprintf("%s left.", u.Name())
	r.Send(message.NewAnnounceMsg(s))
	return nil
}
Beispiel #2
0
// Rename member with a new identity. This will not call rename on the member.
func (r *Room) Rename(oldId string, identity message.Identifier) error {
	if identity.Id() == "" {
		return ErrInvalidName
	}
	err := r.members.Replace(oldId, identity)
	if err != nil {
		return err
	}

	s := fmt.Sprintf("%s is now known as %s.", oldId, identity.Id())
	r.Send(message.NewAnnounceMsg(s))
	return nil
}