func (w *Warp) CientSessions(
	ctx context.Context,
) []*Session {
	sessions := []*Session{}
	w.mutex.Lock()
	for _, user := range w.clients {
		for _, c := range user.sessions {
			sessions = append(sessions, c)
		}
	}
	for _, c := range w.host.UserState.sessions {
		sessions = append(sessions, c)
	}
	w.mutex.Unlock()
	return sessions
}
CientSessions return all connected sessions that are not the host session.
package daemon
import (
	"context"
	"sync"
	"github.com/spolu/warp"
	"github.com/spolu/warp/lib/logging"
	"github.com/spolu/warp/lib/plex"
)
type Warp struct {
	token string
	windowSize warp.Size
	host    *HostState
	clients map[string]*UserState
	data chan []byte
	mutex *sync.Mutex
}
type UserState struct {
	token    string
	username string
	mode     warp.Mode
	sessions map[string]*Session
}
func (u *UserState) User(
	ctx context.Context,
) warp.User {
	return warp.User{
		Token:    u.token,
		Username: u.username,
		Mode:     u.mode,
		Hosting:  false,
	}
}
type HostState struct {
	UserState
	session *Session
}
func (h *HostState) User(
	ctx context.Context,
) warp.User {
	return warp.User{
		Token:    h.UserState.token,
		Username: h.UserState.username,
		Mode:     h.UserState.mode,
		Hosting:  true,
	}
}
func (w *Warp) State(
	ctx context.Context,
) warp.State {
	w.mutex.Lock()
	defer w.mutex.Unlock()
	state := warp.State{
		Warp:       w.token,
		WindowSize: w.windowSize,
		Users:      map[string]warp.User{},
	}
	state.Users[w.host.session.session.User] = w.host.User(ctx)
	for token, user := range w.clients {
		state.Users[token] = user.User(ctx)
	}
	return state
}