本記事では、Claude Code(AIコーディングアシスタント)から Figma を操作するツール Bridgeのアーキテクチャを題材に、HTTP と WebSocket の違い、そして「なぜ WebSocket でなければならないのか」を解説します。 Bridgeは、AIが生成したコードを Figma Plugin API 経由で ...
# base.py import asyncio from fastapi import APIRouter, WebSocket from chat_service import streaming router = APIRouter() async def main(websocket): task = asyncio ...
When a WebSocket connection fails or is terminated, onclose fires with a numeric close code and a reason string that tell you exactly what happened: ws.onclose = (event) => { ...