UNPKG

@ably/cli

Version:

Ably CLI for Pub/Sub, Chat and Spaces

23 lines (22 loc) 864 B
import { ChatClient } from "@ably/chat"; import { AblyBaseCommand } from "./base-command.js"; export class ChatBaseCommand extends AblyBaseCommand { _chatRealtimeClient = null; /** * Create a Chat client and associated resources */ async createChatClient(flags) { // Create Ably Realtime client first const realtimeClient = await this.createAblyRealtimeClient(flags); // Mark auth info as shown after creating the client // to prevent duplicate "Using..." output on subsequent calls this._authInfoShown = true; if (!realtimeClient) { return null; } // Store the realtime client for access by subclasses this._chatRealtimeClient = realtimeClient; // Use the Ably client to create the Chat client return new ChatClient(realtimeClient); } }