ListenTogether V2.2 API
ListenTogether is a .NET 9.0 library for synchronized listening parties. This document covers all public APIs.
ListenTogetherClient
The core class for communicating with the Central Server.
Constructor
Creates a new client instance connected to the ListenTogether Central Server.
Properties
| Property | Type | Description |
|---|---|---|
IsConnected |
bool |
Whether currently connected to server |
IsHost |
bool |
Whether current user is party host |
IsHostOnlyMode |
bool |
Whether party is in host-only control mode |
CanControl |
bool |
Whether user can control playback |
Reconnection |
ReconnectionOptions |
Settings for automatic reconnection |
Party Management Methods
SetUserProfile
Sets and saves the user's nickname (1-50 characters).
CreatePartyAsync
Creates a new party session. Returns the generated PIN (e.g., "ABCD-1234").
JoinPartyAsync
Requests to join a party. Wait for OnJoinApproved event.
ApproveUserAsync
(Host only) Approves or rejects a join request.
DisbandPartyAsync
(Host only) Ends the party for everyone.
Playback Control Methods
Note: Throws InvalidOperationException in host-only mode when called by
non-host.
UpdateStateAsync
Broadcasts playback state update.
SeekToAsync
Seeks to a specific position. Broadcasts to all clients.
SendHeartbeatAsync
Sends current position for sync correction.
SignalTrackFinishedAsync
Notifies server that current track finished.
Queue Management Methods
UpdateQueueAsync
Adds or removes a track. Action: "add" or "remove".
MoveQueueItemAsync
Moves a track within the queue.
ClearQueueAsync
Removes all tracks from queue.
ShuffleQueueAsync
Randomly shuffles the queue.
Playback Mode Methods
SetRepeatModeAsync
Sets repeat mode: Off, One, or All.
SetShuffleAsync
Enables or disables shuffle mode.
Events
Party Events
| Event | Description |
|---|---|
OnUserJoined |
User joined (includes username) |
OnUserLeft |
User left (includes username) |
OnUserRequestingJoin |
(Host) User wants to join |
OnJoinApproved |
Join request approved |
OnPartyDisbanded |
Party ended by host |
ReconnectionOptions
Uses exponential backoff: 500ms -> 1s -> 2s -> 4s -> ... -> max 30s.
ListenTogetherViewModel
MVVM ViewModel using CommunityToolkit.Mvvm.
Observable Properties
| Property | Type | Description |
|---|---|---|
ConnectionState |
ConnectionState |
Current connection state |
Nickname |
string |
User's nickname |
Pin |
string |
Current party PIN |
TargetPin |
string |
PIN to join |
StatusMessage |
string |
Human-readable status |
IsHost |
bool |
Is party host |
IsHostOnlyMode |
bool |
Host-only mode enabled |
CanControl |
bool |
Can control playback |
CurrentTrack |
Track? |
Now playing |
IsPlaying |
bool |
Playback active |
CurrentPositionMs |
double |
Position in ms |
RepeatMode |
RepeatMode |
Current repeat mode |
IsShuffleEnabled |
bool |
Shuffle enabled |
Collections
| Property | Type | Description |
|---|---|---|
Queue |
ObservableCollection<Track> |
Track queue |
Users |
ObservableCollection<ListenTogetherUser> |
Party members |
PendingRequests |
ObservableCollection<ListenTogetherUser> |
Join requests (host) |
Models
Socket.IO Protocol
The client uses standard Socket.IO events to communicate. See source for full event list.