# Generated Centrifugo RPC Client

**DO NOT EDIT** - This file is auto-generated.

## Overview

This directory contains auto-generated Go client code for Centrifugo WebSocket RPC.

## Regeneration

Base command:

```bash
poetry run python manage.py generate_centrifugo_clients --go
```

**Note**: Check `core/management/commands/` for a project-specific wrapper command or a Makefile target that handles output paths and file copying.

## Documentation

Full documentation: https://djangocfg.com/docs/features/integrations/centrifugo/

## Source

- **Generator**: `django_cfg.apps.integrations.centrifugo.codegen`
- **Command**: `generate_centrifugo_clients`
- **Django handlers**: Check your project's Centrifugo RPC handlers decorated with `@websocket_rpc`

## Files

| File | Description |
|------|-------------|
| `types.go` | Go struct definitions |
| `client.go` | Thin wrapper with typed methods |
| `rpc_client.go` | Base Centrifugo RPC client |
| `go.mod` | Go module definition |

## Available Methods

{% if methods %}
{% for method in methods %}
- `{{ method.name_go }}()` - {{ method.docstring }}
{% endfor %}
{% else %}
No RPC methods discovered. Add `@websocket_rpc` decorated handlers.
{% endif %}

## CRITICAL: Authentication

### Token Types

| Token Type | Format | Usage |
|------------|--------|-------|
| **Centrifugo JWT** | `eyJhbGciOi...` | WebSocket connection - USE THIS! |
| CLI Token | `clit_xxx...` | REST API only - NOT for Centrifugo! |

### Getting Centrifugo JWT Token

```json
// GET /cfg/accounts/profile/
{
  "centrifugo": {
    "token": "eyJhbGciOi...",      // <-- Use for CentrifugoRPCClient
    "centrifugo_url": "ws://...",
    "channels": ["user#4"]
  }
}
```

Or use endpoint: `GET /cfg/centrifugo/auth/token/`

### Debugging

If Centrifugo server logs show `user: ""` (empty), authentication failed.
Check that you're using Centrifugo JWT, not CLI token!

## Usage Example

```go
package main

import (
    client "{{ module_path }}"
)

func main() {
    // Create RPC client with JWT from profile.centrifugo.token
    rpc := client.NewCentrifugoRPCClient(
        profile.Centrifugo.CentrifugoURL,
        profile.Centrifugo.Token,  // Must be Centrifugo JWT!
    )

    // Create API client
    api := client.NewAPIClient(rpc)

    // Call RPC methods
{% if methods %}
    result, err := api.{{ methods[0].name_go }}(ctx, params)
{% else %}
    result, err := api.SomeMethod(ctx, params)
{% endif %}
}
```

---
Generated: {{ timestamp }}
