For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
ReferenceGuidesClick-to-Call
ReferenceGuidesClick-to-Call
  • Core
    • Overview
  • SignalWire Client
    • Overview
    • Notifications
    • Client
      • Address Namespace
      • Chat Namespace
      • Conversation Namespace
        • connect
        • dial
        • disconnect
        • getSubscriberInfo
        • offline
        • online
        • updateToken
    • Utility functions
  • Video
    • Overview
    • LocalOverlay
    • RoomSession
    • RoomSessionDevice
    • RoomSessionPlayback
    • RoomSessionRecording
    • RoomSessionScreenShare
    • RoomSessionStream
    • RoomDevice
    • RoomScreenShare
  • Chat
    • Overview
    • Client
    • ChatMember
    • ChatMemberEntity
    • ChatMessage
    • ChatMessageEntity
  • PubSub
    • Overview
    • Client
    • PubSubMessage
  • WebRTC
    • Overview
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • online
SignalWire ClientClientMethods

online

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

updateToken

Next
Built with

online

  • online(options): Promise<Call>

Set the client to be online so it can receive call invites via WebRTC. The call invites can be accepted or rejected as per user input.

Parameters

options
objectRequired

Options object

options.incomingCallHandlers
IncomingCallHandlers

Callback functions for when a call is received. See IncomingCallHandlers.

Example

1// Receive calls using websocket notifications
2client.online({
3 incomingCallHandlers: {
4 all: __incomingCallHandler,
5 },
6});
7
8// Function to handle the incoming call notification and stores the invite
9window.__incomingCallHandler = (notification) => {
10 if (
11 !window.__invite ||
12 window.__invite.details.callID !== notification.invite.details.callID
13 ) {
14 // Store call invite
15 window.__invite = notification.invite;
16 }
17
18 // Trigger UI update here to convey the ringing state
19};
20
21// Function to answer the call
22window.answer = async () => {
23 // Accept the call invite
24 const call = await window.__invite.accept({
25 rootElement: document.getElementById("rootElement"),
26 });
27
28 // Trigger UI update here to convey the connected state
29};
30
31// Function to reject the call
32window.reject = async () => {
33 await window.__invite.reject();
34
35 // Trigger UI update here to convey the ready state
36};