# Socket.IO — Live Auction Events (ReValue)

Bid **validation and row locking** always run in Laravel (`POST /api/client/auctions/{id}/bids`).  
Node only joins rooms and broadcasts after Laravel accepts the bid.

## Handshake

Same as chat, plus optional:

| Param | Required for bidding |
|---|---|
| `token` | Sanctum bearer token (or pass `token` on each `place-bid`) |

`userType` for buyers: `client` (or legacy `user`).

## Client → Server

### `enter-auction`
```json
{ "listing_id": 12 }
```
Joins room `auction:12`.

### `exit-auction`
```json
{ "listing_id": 12 }
```

### `place-bid`
```json
{
  "listing_id": 12,
  "amount": 1050,
  "token": "<sanctum token>"
}
```
Proxies to Laravel, then emits room updates.

## Server → Client

| Event | When |
|---|---|
| `auction-joined` | You joined a room |
| `auction-viewer-joined` / `auction-viewer-left` | Presence |
| `auction-bid-accepted` | Your bid succeeded (to you) |
| `auction-bid-failed` | Laravel rejected the bid (to you) |
| `auction-updated` | Room state after any accepted bid |
| `auction-outbid` | Toast payload for previous leader (`outbid_client_id`) |

`auction-updated` payload mirrors Laravel bidding room state (`current_price`, `minimum_next_bid`, `quick_increments`, `bidders_count`, `recent_bids`, anonymized names, etc.).

## REST companions

- `GET /api/client/auctions/{id}/bidding-room`
- `POST /api/client/auctions/{id}/bids`
- `GET /api/client/auctions/{id}/bidders`
- `GET /api/provider/listings/{id}/bidders`
