> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Lifecycle

## Overview

The following flow is a simplified representation of the lifecycle of a WebSocket connection between a client and a
server. It includes the initialization phase, the operation phase, and the shutdown phase.

```mermaid theme={null}
sequenceDiagram
    participant Client
    participant Server

    Note over Client,Server: Initialization Phase

    Client->>Server: "status/initialize" request
    activate Server
    Server-->>Client: "status/initialize" response
    deactivate Server

    Note over Client,Server: Operation Phase
    Server<<->>Client: Normal bidirectional exchange of messages

    Note over Client,Server: Shutdown
    Client<<->>Server: Disconnect

    Note over Client,Server: Connection closed
```

Initialization phase is the first step in establishing a WebSocket connection between a client and a server.
This phase is crucial for setting up the necessary parameters and ensuring that both parties are ready for
communication.

Upon successful initialization, server and client begin the operation phase, where they can exchange messages
bidrectionally. This phase allows for real-time communication and data transfer between the two parties.

Finally, the shutdown phase occurs when either the client or server decides to terminate the connection.

## Reference

### Messages

#### `status/initialize` Message

Request to initialize the connection sent by a client.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "status/initialize",
  "params": {
    "client_info": {
      "name": "Example Client",
      "version": "1.0.1"
    }
  }
}
```

Server is expected to provide a response with the server information.

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "server_info": {
      "name": "BlobHub Realtime Server",
      "version": "1.0.1"
    }
  }
}
```
