Skip to content

Events Guide

All Available Events

The SDK provides the following events, accessible through VmosEdgeClientEvents constants:

Event NameConstantDescriptionEvent Data
Size ChangedSIZE_CHANGEDTriggered when video stream size or rotation changesVmosEdgeSizeChangedEvent
ErrorERRORTriggered when an error occursVmosEdgeErrorEvent
Connection SuccessSTARTEDTriggered when connection is established and video stream starts playingvoid (no data)
Connection StoppedSTOPPEDTriggered when client stops running (active stop or critical error)void (no data)
Clipboard ChangedCLIPBOARD_CHANGEDTriggered when device clipboard content changesstring (clipboard content)
Channel ConnectedCHANNEL_CONNECTEDTriggered when a single channel (video/audio/touch) connection is establishedVmosEdgeChannelConnectedEvent
Group Control Device JoinedGROUP_CONTROL_JOINEDTriggered when a slave device successfully joins the group control groupVmosEdgeClientConfig
Group Control Device LeftGROUP_CONTROL_LEAVETriggered when a slave device leaves the group control groupVmosEdgeClientConfig

Event Usage Examples

typescript
import {
  VmosEdgeClient,
  VmosEdgeClientEvents,
  type VmosEdgeErrorEvent,
  type VmosEdgeSizeChangedEvent,
} from "@vmosedge/web-sdk";

const client = new VmosEdgeClient({ /* ... */ });

// Connection success
client.on(VmosEdgeClientEvents.STARTED, () => {
  console.log("✅ Device connected successfully, screen is ready");
});

// Connection stopped
client.on(VmosEdgeClientEvents.STOPPED, () => {
  console.log("⏹️ Connection stopped");
});

// Error handling
client.on(VmosEdgeClientEvents.ERROR, (error: VmosEdgeErrorEvent) => {
  console.error(`❌ Error occurred [${error.code}]: ${error.message}`);
  
  // Handle different error types
  switch (error.type) {
    case "connection":
      console.error("Connection error, please check network and device status");
      break;
    case "video":
      console.error("Video stream error, please check video port");
      break;
    case "touch":
      console.error("Touch channel error, please check touch port");
      break;
  }
});

// Size change
client.on(
  VmosEdgeClientEvents.SIZE_CHANGED,
  (size: VmosEdgeSizeChangedEvent) => {
    console.log(`📐 Screen size changed: ${size.videoWidth} x ${size.videoHeight}`);
    console.log(`🔄 Rotation state: ${size.rotation === 0 ? "Portrait" : "Landscape"}`);
  }
);

// Clipboard change
client.on(VmosEdgeClientEvents.CLIPBOARD_CHANGED, (content: string) => {
  console.log(`📋 Clipboard content changed: ${content}`);
});

// Channel connection
client.on(VmosEdgeClientEvents.CHANNEL_CONNECTED, (event) => {
  console.log(`🔌 ${event.channel} channel connected successfully`);
});

Powered by VMOS Edge Team