# ProxyBackendResolver

Chooses which backend voice listener a connecting player is relayed to, overriding the servers: map in the relay's own config.yml.

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

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

public interface ProxyBackendResolver { ... }
```

Chooses which backend voice listener a connecting player is relayed to, overriding the
`servers:` map in the relay's own `config.yml`.

Registered resolvers are consulted in registration order, before the configured map. The
first one to return a present value wins; returning `Optional#empty()` passes the decision
on, and if every resolver passes, the relay falls back to its configured map exactly as it does
with no addon installed. A resolver that throws is logged and treated as empty, so a broken
addon degrades to default routing rather than breaking voice for the network.

Called on the relay's own per-connection thread, once per incoming connection, before any
bytes are forwarded. Keep it fast and non-blocking: a slow resolver delays that player's voice
connection. It must be safe to call from multiple threads at once.

## Methods

### resolve

```java
Optional<InetSocketAddress> resolve(UUID playerId, Optional<String> serverName)
```

| Parameter | Description |
| --- | --- |
| `playerId` | the connecting player as the client claims; unverified until the backend checks its token, so do not route on it to anything that trusts it |
| `serverName` | the backend the proxy believes the player is on, or empty when the proxy itself could not resolve one (a race right after a server switch, or a player who is not currently connected). Returning a present value here is the only way to relay such a connection instead of rejecting it. |

**Returns:** the backend voice address to use, or empty to defer to the next resolver / the configured `servers:` map