# Signaling Server for AeThex Connect

This is a minimal Socket.io signaling server for WebRTC voice and game sync, using Supabase JWT authentication.

## Features
- Authenticates users via Supabase JWT
- Handles WebRTC signaling (voice:join, offer, answer, ice-candidate, leave)
- Handles basic game sync events (game:join, game:position)

## Usage

### 1. Environment Variables
Create a `.env` file in this directory with:

```
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-supabase-anon-key
PORT=4000
```

### 2. Install Dependencies

```
npm install socket.io node-fetch dotenv
```

### 3. Run the Server

```
node signaling-server.js
```

## Frontend Usage
- Connect to the server with Socket.io
- Pass the Supabase JWT as `auth.token` in the connection options

```js
const socket = io('https://your-signaling-server', {
  auth: { token: supabase.auth.getSession().access_token }
});
```

## Deployment
- Deploy to Railway, Fly.io, or any Node.js host
- Make sure to set the environment variables in your deployment settings

---

**This server does not store any data. All persistent data (users, messages, game state) should remain in Supabase.**
