# ProxyRelayListener

Observes the relay's connection lifecycle.

Source: https://socketsvc.vercel.app/api/proxy/ProxyRelayListener
<Callout title="Generated from source">
  Interface `com.socketsvc.proxy.api.ProxyRelayListener` — generated from [ProxyRelayListener.java](https://github.com/HippoDev03/SocketSVC/blob/main/proxy/common/src/main/java/com/socketsvc/proxy/api/ProxyRelayListener.java). Edit the Javadoc in the Java source, then run `pnpm gen:api`.
</Callout>

```java
package com.socketsvc.proxy.api;

public interface ProxyRelayListener { ... }
```

Observes the relay's connection lifecycle. Every method is a no-op by default, so an addon only
overrides what it needs.

Callbacks run on the relay's own threads, never on the proxy's main thread, and a listener
that throws is logged and skipped rather than breaking the connection. Do not block in them: the
open callback runs before the connection is piped, and the close callback runs as it is torn
down. These report relay activity only — the relay never decodes audio, so there is nothing here
about speaking, volume or positions. Those live on the backend's own spatial audio API.

## Methods

### onRelayOpened

```java
default void onRelayOpened(RelaySession session)
```

A connection was matched to a backend and is about to be piped through. Before the backend
has checked its token: the session's player id is only what the client claimed.

### onRelayClosed

```java
default void onRelayClosed(RelaySession session)
```

A previously opened relay finished, for any reason (either side closed, or the relay stopped).

### onRelayRejected

```java
default void onRelayRejected(UUID playerId, String reason)
```

An incoming connection was closed without being relayed.

| Parameter | Description |
| --- | --- |
| `playerId` | the connecting player, or `null` when the connection never supplied a usable `uuid` query parameter |
| `reason` | a short human-readable explanation, the same text written to the proxy log |