Files
Baradb/docs/tr/api-websocket.md
T

980 B
Raw Blame History

WebSocket API

Gerçek zamanlı veri akışları ve anlık bildirimler için tam çift yönlü akış.

Bağlantı

ws://localhost:9471/ws

İstemci Örneği

const ws = new WebSocket('ws://localhost:9471/ws');

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: 'query',
    sql: 'SELECT * FROM users'
  }));
};

ws.onmessage = (event) => {
  console.log('Received:', JSON.parse(event.data));
};

Mesaj Formatı

{
  "type": "query",
  "id": "uuid",
  "sql": "SELECT * FROM users"
}

Mesaj Türleri

Sorgu İsteği

{
  "type": "query",
  "id": "123",
  "sql": "SELECT * FROM users"
}

Sorgu Yanıtı

{
  "type": "result",
  "id": "123",
  "data": [{"id": 1, "name": "Alice"}]
}

Abonelik

{
  "type": "subscribe",
  "table": "users"
}

Anlık Bildirim

{
  "type": "push",
  "table": "users",
  "action": "insert",
  "data": {"id": 3, "name": "Charlie"}
}