calling

package
v2.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

README

Calling

The Calling module provides a comprehensive client for the Webex Calling APIs, including REST APIs (call history, call settings, voicemail, contacts) and real-time call control (line registration, dial, hold, transfer, DTMF) with WebRTC media via Mobius/BroadWorks signaling.

Overview

This package covers the full Webex Calling stack:

  1. REST APIs — Call history, call settings (DND, call waiting, call forwarding, voicemail), contacts
  2. Real-time Call Control — Line registration with Mobius, outbound/inbound calls, hold/resume, transfer, DTMF
  3. WebRTC Media — Pion-based PeerConnection management for Mobius, SDP munging for BroadWorks compatibility
  4. Audio Bridge — Browser-facing WebRTC PeerConnection with bidirectional RTP relay between browser and Mobius
  5. Mercury Integration — Automatic Mercury WebSocket wiring for Mobius call events (ROAP answers, call progress, disconnect)

Installation

This module is part of the Webex Go SDK. To use it, import the SDK and the calling package:

import (
    webex "github.com/WebexCommunity/webex-go-sdk/v2"
    "github.com/WebexCommunity/webex-go-sdk/v2/calling"
)

Architecture

flowchart LR
    Browser["Browser"]
    AB["AudioBridge"]
    MPC["Mobius PeerConnection"]
    BW["BroadWorks"]
    ST["SignalingTransport\n(WebSocket, etc.)"]
    Mercury["Mercury WS\n(ROAP signaling)"]

    Browser <-->|WebRTC| AB
    AB <-->|RTP relay| MPC
    MPC <-->|WebRTC| BW
    AB --- ST
    MPC --- Mercury

The SDK manages:

  • AudioBridge: Browser-facing PeerConnection, silence keepalive, bidirectional RTP relay
  • CallingClient: Line registration, call lifecycle, Mercury event routing, AudioBridge auto-binding
  • MediaEngine: Mobius-facing PeerConnection, SDP munging, codec negotiation (PCMU/PCMA only)
  • Call: Individual call state machine, ROAP signaling, Mobius HTTP API

Usage

Initializing the Client
client, err := webex.NewClient(accessToken, nil)
if err != nil {
    log.Fatalf("Error creating client: %v", err)
}

// Access calling sub-clients
callingClient := client.Calling()
REST APIs
Call History
data, err := client.Calling().CallHistory().GetCallHistoryData(
    7,                      // days
    10,                     // limit
    calling.SortDESC,       // sort order
    calling.SortByStartTime, // sort by
)
Call Settings
// Get Do Not Disturb
dnd, err := client.Calling().CallSettings().GetDoNotDisturbSetting()

// Set Do Not Disturb
dnd, err := client.Calling().CallSettings().SetDoNotDisturbSetting(true)

// Get Call Waiting
cw, err := client.Calling().CallSettings().GetCallWaitingSetting()

// Get Call Forwarding
cf, err := client.Calling().CallSettings().GetCallForwardSetting()

// Get/Set Voicemail Settings
vm, err := client.Calling().CallSettings().GetVoicemailSetting()
Voicemail
// List voicemails
list, err := client.Calling().Voicemail().GetVoicemailList(0, 20, calling.SortDESC)

// Get summary
summary, err := client.Calling().Voicemail().GetVoicemailSummary()

// Mark as read/unread
_, err = client.Calling().Voicemail().MarkAsRead("MESSAGE_ID")
_, err = client.Calling().Voicemail().MarkAsUnread("MESSAGE_ID")

// Get transcript
transcript, err := client.Calling().Voicemail().GetTranscript("MESSAGE_ID")

// Delete
_, err = client.Calling().Voicemail().Delete("MESSAGE_ID")
Contacts
// List contacts
contacts, err := client.Calling().Contacts().GetContacts()

// Create a contact
_, err = client.Calling().Contacts().CreateContact(calling.Contact{...})

// Create a contact group
_, err = client.Calling().Contacts().CreateContactGroup("Group Name", "", calling.GroupTypeNormal)

// Delete
_, err = client.Calling().Contacts().DeleteContact("CONTACT_ID")
_, err = client.Calling().Contacts().DeleteContactGroup("GROUP_ID")
Real-Time Call Control
Registration
// Create a CallingClient for real-time call control
cc := client.Calling().CallingClient(&calling.CallingClientConfig{
    ClientDeviceURI: "", // optional, auto-discovered via WDM
})

// Discover Mobius servers (WDM device registration + region discovery)
if err := cc.DiscoverMobiusServers(); err != nil {
    log.Fatalf("Discovery failed: %v", err)
}

// Or set Mobius servers manually
cc.SetMobiusServers([]string{"https://mobius.example.com/api/v1/calling/web/"}, nil)

// Register a line with Mobius
line, err := cc.CreateLine()
if err != nil {
    log.Fatalf("Registration failed: %v", err)
}
log.Printf("Registered: lineId=%s deviceId=%s", line.LineID, line.GetDeviceID())
Mercury Connection

Mercury delivers Mobius call events (ROAP answers, call progress, disconnect) over WebSocket. The SDK handles all wiring automatically:

// Connect Mercury — uses WDM WebSocket URL from registration,
// registers wildcard handler, filters mobius.* events, routes to CallingClient
merc := client.Mercury()
if err := cc.ConnectMercury(merc); err != nil {
    log.Fatalf("Mercury failed: %v", err)
}

// Check status
if cc.IsMercuryConnected() {
    log.Println("Mercury connected")
}

// Disconnect (also called automatically by cc.Shutdown())
cc.DisconnectMercury()
Making a Call
// Normalize the dial address (phone number, SIP URI, or tel: URI)
address, callType, err := calling.NormalizeAddress("+1 (408) 555-1234")
// address = "tel:+14085551234", callType = calling.CallTypeURI

call, err := cc.MakeCall(line, &calling.CallDetails{
    Type:    callType,
    Address: address,
})
if err != nil {
    log.Fatalf("Dial failed: %v", err)
}

log.Printf("Dialing: callId=%s", call.GetCallID())
Call Operations
// Hold / Resume
call.Hold()
call.Resume()
call.DoHoldResume() // toggle

// Mute / Unmute
call.Mute()
call.Unmute()

// Send DTMF
call.SendDigit("5")

// Transfer (blind)
call.CompleteTransfer(calling.TransferTypeBlind, "", "+14085559999")

// Transfer (consult)
call.CompleteTransfer(calling.TransferTypeConsult, "OTHER_CALL_ID", "")

// End call
call.End()
Call Events
// Listen for disconnect
call.Emitter.On(string(calling.CallEventDisconnect), func(data interface{}) {
    log.Println("Call disconnected")
})

// Listen for incoming calls on a line
cc.Emitter.On(string(calling.LineEventIncomingCall), func(data interface{}) {
    incomingCall := data.(*calling.Call)
    log.Printf("Incoming call: %s", incomingCall.GetCallID())
})
Call State
call.GetCallID()        // Mobius call ID
call.GetCorrelationID() // correlation ID
call.GetDirection()     // CallDirectionOutbound or CallDirectionInbound
call.GetState()         // CallStateIdle, CallStateConnected, CallStateHeld, etc.
call.IsConnected()
call.IsMuted()
call.IsHeld()
Audio Bridge

The AudioBridge manages a browser-facing WebRTC PeerConnection and bidirectional RTP relay between the browser and Mobius. It handles:

  • PCMU/PCMA codec negotiation (matching Mobius)
  • Silence keepalive to prevent browser PC timeout
  • Browser→Mobius RTP relay (gated on Mobius PC connection)
  • Mobius→Browser RTP relay (starts when Mobius remote track arrives)
Creating an AudioBridge
bridge, err := calling.NewAudioBridge(nil) // uses default config (Google STUN)
if err != nil {
    log.Fatalf("Failed to create audio bridge: %v", err)
}
defer bridge.Close()

// Or with custom config
bridge, err := calling.NewAudioBridge(&calling.AudioBridgeConfig{
    ICEServers: []webrtc.ICEServer{
        {URLs: []string{"stun:stun.example.com:3478"}},
    },
})
Auto-Binding with CallingClient

Register the bridge with CallingClient for automatic attach/detach on call lifecycle:

cc.SetAudioBridge(bridge)
// Now MakeCall() automatically attaches the bridge, and
// call disconnect automatically detaches it.

// Clear when done
cc.ClearAudioBridge()
WebRTC Signaling

The SignalingTransport interface abstracts the signaling channel (WebSocket, gRPC, HTTP polling, etc.):

// Implement SignalingTransport for your transport
type wsTransport struct{ conn *websocket.Conn }

func (t *wsTransport) ReadMessage() ([]byte, error) {
    _, data, err := t.conn.ReadMessage()
    return data, err
}
func (t *wsTransport) WriteMessage(data []byte) error {
    return t.conn.WriteMessage(websocket.TextMessage, data)
}

// HandleSignaling blocks until the transport closes
err := bridge.HandleSignaling(&wsTransport{conn: wsConn})

The signaling protocol uses JSON messages:

Type Direction Fields
offer Browser → Server type, sdp
answer Server → Browser type, sdp
ice-candidate Both directions type, candidate
Manual Signaling (Advanced)

If you need more control over the signaling flow:

pc := bridge.PeerConnection()

// Set callbacks
bridge.OnICECandidate(func(c *webrtc.ICECandidate) {
    // Send candidate to browser
})
bridge.OnConnectionStateChange(func(state webrtc.PeerConnectionState) {
    log.Printf("Browser PC state: %s", state)
})

// Manually attach/detach calls
bridge.AttachCall(call)
bridge.DetachCall()
Shutdown
// Shutdown deregisters all lines, disconnects Mercury, clears AudioBridge
cc.Shutdown()

// Or clean up stale devices from previous sessions
deleted, err := cc.DeregisterAllDevices()
log.Printf("Cleaned up %d stale devices", deleted)

Data Structures

Key Types
Type Description
CallingClient Main orchestrator for lines, calls, Mercury, and AudioBridge
Line Represents a registered line with Mobius
Call Represents an active call with state machine and media
AudioBridge Browser-facing WebRTC PeerConnection with RTP relay
MediaEngine Mobius-facing WebRTC PeerConnection with SDP munging
Call States
State Description
CallStateIdle Initial state before dialing
CallStateAlerting Ringing (incoming) or proceeding (outgoing)
CallStateConnected Call is active with media flowing
CallStateHeld Call is on hold
CallStateDisconnected Call has ended
Call Events
Event Description
CallEventAlerting Call is ringing
CallEventConnect Call connected
CallEventDisconnect Call ended
CallEventHeld Call placed on hold
CallEventResumed Call resumed from hold
CallEventRemoteMedia Remote media (SDP answer) received
Line Events
Event Description
LineEventConnecting Line registration in progress
LineEventRegistered Line registered successfully
LineEventUnregistered Line deregistered
LineEventIncomingCall Incoming call on this line
Address Normalization

NormalizeAddress() handles all address formats:

Input Output Call Type
+1 (408) 555-1234 tel:+14085551234 CallTypeURI
tel:+14085551234 tel:+14085551234 CallTypeURI
sip:user@example.com sip:user@example.com CallTypeURI

Complete Example

Here's a complete example demonstrating registration, Mercury connection, audio bridge setup, and making a call:

package main

import (
    "log"
    "os"

    "github.com/gorilla/websocket"

    webex "github.com/WebexCommunity/webex-go-sdk/v2"
    "github.com/WebexCommunity/webex-go-sdk/v2/calling"
)

func main() {
    accessToken := os.Getenv("WEBEX_ACCESS_TOKEN")
    if accessToken == "" {
        log.Fatal("WEBEX_ACCESS_TOKEN required")
    }

    // 1. Create Webex client
    client, err := webex.NewClient(accessToken, nil)
    if err != nil {
        log.Fatalf("Client error: %v", err)
    }

    // 2. Create CallingClient and discover Mobius
    cc := client.Calling().CallingClient(&calling.CallingClientConfig{})
    if err := cc.DiscoverMobiusServers(); err != nil {
        log.Fatalf("Discovery failed: %v", err)
    }

    // 3. Register a line
    line, err := cc.CreateLine()
    if err != nil {
        log.Fatalf("Registration failed: %v", err)
    }
    log.Printf("Registered: lineId=%s deviceId=%s", line.LineID, line.GetDeviceID())

    // 4. Connect Mercury for call events
    go func() {
        if err := cc.ConnectMercury(client.Mercury()); err != nil {
            log.Printf("Mercury failed: %v", err)
        }
    }()

    // 5. Create AudioBridge and register with CallingClient
    bridge, err := calling.NewAudioBridge(nil)
    if err != nil {
        log.Fatalf("AudioBridge error: %v", err)
    }
    defer bridge.Close()
    cc.SetAudioBridge(bridge)

    // 6. Handle browser WebSocket signaling (in your HTTP handler)
    // bridge.HandleSignaling(&yourWSTransport{conn: wsConn})

    // 7. Make a call (AudioBridge auto-attaches)
    address, ct, _ := calling.NormalizeAddress("+14085551234")
    call, err := cc.MakeCall(line, &calling.CallDetails{
        Type:    ct,
        Address: address,
    })
    if err != nil {
        log.Fatalf("Dial failed: %v", err)
    }
    log.Printf("Call started: %s", call.GetCallID())

    // 8. Listen for events
    call.Emitter.On(string(calling.CallEventDisconnect), func(d interface{}) {
        log.Println("Call disconnected")
    })

    // 9. Cleanup
    // cc.Shutdown() // deregisters lines, disconnects Mercury, clears bridge
}

Error Handling

All methods return structured errors from the webexsdk package. Use the convenience functions to check error types:

history, err := client.Calling().GetCallHistory(nil)
if err != nil {
    switch {
    case webexsdk.IsAuthError(err):
        log.Println("Invalid or expired access token")
    case webexsdk.IsRateLimited(err):
        log.Println("Rate limited — SDK retries automatically")
    case webexsdk.IsServerError(err):
        log.Println("Server error — SDK retries automatically")
    default:
        log.Printf("Error: %v", err)
    }
}

See webexsdk/Readme.md for the full error type reference.

Documentation

Overview

Package calling provides a client for the Webex Calling APIs. It includes sub-clients for Call History, Call Settings, Voicemail, and Contacts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModifySdpForMobius

func ModifySdpForMobius(sdp string) string

ModifySdpForMobius cleans up the SDP offer for BroadWorks/Mobius compatibility: - Removes IPv6 candidates (BroadWorks only supports IPv4) - Converts port 9 to 0 in m= line (JS SDK: convertPort9to0) - Removes rtcp-fb lines (BroadWorks doesn't support transport-cc) - Removes extmap lines (BroadWorks doesn't support RTP header extensions) - Removes extmap-allow-mixed

func RoapToSDP

func RoapToSDP(roap *RoapMessage) string

RoapToSDP extracts the SDP from a ROAP message received from Mobius

Types

type Address

type Address struct {
	City    string `json:"city,omitempty"`
	Country string `json:"country,omitempty"`
	State   string `json:"state,omitempty"`
	Street  string `json:"street,omitempty"`
	ZipCode string `json:"zipCode,omitempty"`
}

Address represents a physical address

type AudioBridge

type AudioBridge struct {
	// contains filtered or unexported fields
}

AudioBridge manages a browser-facing WebRTC PeerConnection and bidirectional RTP relay between the browser and a Mobius Call.

Usage:

bridge, err := calling.NewAudioBridge(nil)
// Use bridge.PeerConnection() for WebRTC signaling with the browser.
// Call bridge.AttachCall(call) when a Call is active.
// Call bridge.Close() when done.

func NewAudioBridge

func NewAudioBridge(config *AudioBridgeConfig) (*AudioBridge, error)

NewAudioBridge creates a new AudioBridge with a browser-facing PeerConnection. The PeerConnection is configured with only PCMU/PCMA codecs to match Mobius.

func (*AudioBridge) AttachCall

func (ab *AudioBridge) AttachCall(call *Call)

AttachCall attaches a Call to the bridge, enabling bidirectional audio relay. Can be called before or after the call is connected — the relay goroutines will wait for the call's Mobius PC to reach connected state.

func (*AudioBridge) Close

func (ab *AudioBridge) Close() error

Close stops all relay goroutines and closes the browser PeerConnection.

func (*AudioBridge) DetachCall

func (ab *AudioBridge) DetachCall()

DetachCall removes the current call from the bridge.

func (*AudioBridge) GetCall

func (ab *AudioBridge) GetCall() *Call

GetCall returns the currently attached call, or nil.

func (*AudioBridge) HandleSignaling

func (ab *AudioBridge) HandleSignaling(transport SignalingTransport) error

HandleSignaling runs the WebRTC signaling loop over the given transport. It forwards ICE candidates to the browser, processes incoming SDP offers and ICE candidates, and blocks until the transport returns an error (e.g. connection closed). Call this from your WebSocket handler.

Example with gorilla/websocket:

bridge.HandleSignaling(&gorillaTransport{conn: wsConn})

func (*AudioBridge) LocalTrack

func (ab *AudioBridge) LocalTrack() *webrtc.TrackLocalStaticRTP

LocalTrack returns the local track used to send Mobius audio to the browser.

func (*AudioBridge) OnConnectionStateChange

func (ab *AudioBridge) OnConnectionStateChange(handler func(state webrtc.PeerConnectionState))

OnConnectionStateChange sets the callback for browser PC connection state changes.

func (*AudioBridge) OnICECandidate

func (ab *AudioBridge) OnICECandidate(handler func(candidate *webrtc.ICECandidate))

OnICECandidate sets the callback for when an ICE candidate is gathered on the browser-facing PeerConnection.

func (*AudioBridge) PeerConnection

func (ab *AudioBridge) PeerConnection() *webrtc.PeerConnection

PeerConnection returns the browser-facing PeerConnection for signaling.

type AudioBridgeConfig

type AudioBridgeConfig struct {
	// ICEServers for the browser-facing PeerConnection.
	// Default: Google STUN server.
	ICEServers []webrtc.ICEServer
}

AudioBridgeConfig holds configuration for creating an AudioBridge.

func DefaultAudioBridgeConfig

func DefaultAudioBridgeConfig() *AudioBridgeConfig

DefaultAudioBridgeConfig returns an AudioBridgeConfig with sensible defaults.

type AudioTrackWriter

type AudioTrackWriter interface {
	WriteSample(sample []byte, duration uint32) error
}

AudioTrackWriter is an interface for writing audio samples to a track

type BusinessContinuitySetting

type BusinessContinuitySetting struct {
	Enabled                     bool   `json:"enabled"`
	DestinationVoicemailEnabled *bool  `json:"destinationVoicemailEnabled,omitempty"`
	Destination                 string `json:"destination,omitempty"`
}

BusinessContinuitySetting configures forwarding when the line is offline

type Call

type Call struct {

	// Events
	Emitter *EventEmitter
	// contains filtered or unexported fields
}

Call represents an active or pending call with full call control. It manages the Mobius signaling and Pion WebRTC media layer.

func NewCall

func NewCall(core *webexsdk.Client, direction CallDirection, destination *CallDetails, config *CallConfig) (*Call, error)

NewCall creates a new Call instance

func (*Call) Answer

func (c *Call) Answer(remoteOffer string) error

Answer answers an incoming call. It sets the remote SDP offer, creates an answer, and sends it via ROAP.

func (*Call) CompleteTransfer

func (c *Call) CompleteTransfer(transferType TransferType, transferCallID, transferTarget string) error

CompleteTransfer completes a call transfer (blind or consult)

func (*Call) Dial

func (c *Call) Dial() error

Dial initiates an outbound call. It creates a WebRTC offer, wraps it in ROAP, and POSTs to Mobius.

func (*Call) DoHoldResume

func (c *Call) DoHoldResume() error

DoHoldResume toggles hold/resume

func (*Call) End

func (c *Call) End() error

End disconnects the call

func (*Call) GetCallID

func (c *Call) GetCallID() string

GetCallID returns the call ID

func (*Call) GetCorrelationID

func (c *Call) GetCorrelationID() string

GetCorrelationID returns the correlation ID

func (*Call) GetDirection

func (c *Call) GetDirection() CallDirection

GetDirection returns the call direction

func (*Call) GetDisconnectReason

func (c *Call) GetDisconnectReason() DisconnectReason

GetDisconnectReason returns the disconnect reason

func (*Call) GetMedia

func (c *Call) GetMedia() *MediaEngine

GetMedia returns the media engine for direct RTP access

func (*Call) GetState

func (c *Call) GetState() CallState

GetState returns the current call state

func (*Call) HandleMobiusEvent

func (c *Call) HandleMobiusEvent(event *MobiusCallEvent)

HandleMobiusEvent processes an incoming Mobius WebSocket event for this call

func (*Call) Hold

func (c *Call) Hold() error

Hold puts the call on hold

func (*Call) IsConnected

func (c *Call) IsConnected() bool

IsConnected returns true if the call is connected

func (*Call) IsHeld

func (c *Call) IsHeld() bool

IsHeld returns true if the call is on hold

func (*Call) IsMuted

func (c *Call) IsMuted() bool

IsMuted returns true if the call is muted

func (*Call) Mute

func (c *Call) Mute()

Mute mutes the local audio

func (*Call) PostStatus

func (c *Call) PostStatus() error

PostStatus sends a call keepalive/status to Mobius

func (*Call) Resume

func (c *Call) Resume() error

Resume resumes a held call

func (*Call) SendDigit

func (c *Call) SendDigit(tone string) error

SendDigit sends a DTMF digit during the call

func (*Call) Unmute

func (c *Call) Unmute()

Unmute unmutes the local audio

type CallConfig

type CallConfig struct {
	// MobiusURL is the active Mobius server URL
	MobiusURL string
	// DeviceID is the registered Mobius device ID
	DeviceID string
	// LineID is the line ID this call belongs to
	LineID string
	// ClientDeviceURI is the Webex device URL
	ClientDeviceURI string
	// MediaConfig is the WebRTC media configuration
	MediaConfig *MediaConfig
}

CallConfig holds configuration for creating a call

type CallDetails

type CallDetails struct {
	Type    CallType `json:"type"`
	Address string   `json:"address"`
}

CallDetails contains the destination for an outbound call

type CallDirection

type CallDirection string

CallDirection indicates whether a call is inbound or outbound

const (
	CallDirectionInbound  CallDirection = "inbound"
	CallDirectionOutbound CallDirection = "outbound"
)

type CallEventKey

type CallEventKey string

CallEventKey identifies the type of call event

const (
	CallEventAlerting      CallEventKey = "alerting"
	CallEventProgress      CallEventKey = "progress"
	CallEventConnect       CallEventKey = "connect"
	CallEventEstablished   CallEventKey = "established"
	CallEventDisconnect    CallEventKey = "disconnect"
	CallEventHeld          CallEventKey = "held"
	CallEventResumed       CallEventKey = "resumed"
	CallEventRemoteMedia   CallEventKey = "remote_media"
	CallEventCallerID      CallEventKey = "caller_id"
	CallEventError         CallEventKey = "call_error"
	CallEventHoldError     CallEventKey = "hold_error"
	CallEventResumeError   CallEventKey = "resume_error"
	CallEventTransferError CallEventKey = "transfer_error"
)

type CallForwardAlwaysSetting

type CallForwardAlwaysSetting struct {
	Enabled                     bool   `json:"enabled"`
	RingReminderEnabled         *bool  `json:"ringReminderEnabled,omitempty"`
	DestinationVoicemailEnabled *bool  `json:"destinationVoicemailEnabled,omitempty"`
	Destination                 string `json:"destination,omitempty"`
}

CallForwardAlwaysSetting configures always-on call forwarding

type CallForwardBusySetting

type CallForwardBusySetting struct {
	Enabled                     bool   `json:"enabled"`
	DestinationVoicemailEnabled *bool  `json:"destinationVoicemailEnabled,omitempty"`
	Destination                 string `json:"destination,omitempty"`
}

CallForwardBusySetting configures call forwarding when the line is busy

type CallForwardNoAnswerSetting

type CallForwardNoAnswerSetting struct {
	Enabled                     bool   `json:"enabled"`
	NumberOfRings               *int   `json:"numberOfRings,omitempty"`
	SystemMaxNumberOfRings      *int   `json:"systemMaxNumberOfRings,omitempty"`
	DestinationVoicemailEnabled *bool  `json:"destinationVoicemailEnabled,omitempty"`
	Destination                 string `json:"destination,omitempty"`
}

CallForwardNoAnswerSetting configures call forwarding when unanswered

type CallForwardSetting

type CallForwardSetting struct {
	CallForwarding     CallForwardingConfig      `json:"callForwarding"`
	BusinessContinuity BusinessContinuitySetting `json:"businessContinuity"`
}

CallForwardSetting is the full call forward configuration

type CallForwardingConfig

type CallForwardingConfig struct {
	Always   CallForwardAlwaysSetting   `json:"always"`
	Busy     CallForwardBusySetting     `json:"busy"`
	NoAnswer CallForwardNoAnswerSetting `json:"noAnswer"`
}

CallForwardingConfig groups all call forwarding rules

type CallHistoryClient

type CallHistoryClient struct {
	// contains filtered or unexported fields
}

CallHistoryClient provides methods for retrieving and managing call history records.

func (*CallHistoryClient) DeleteCallHistoryRecords

func (c *CallHistoryClient) DeleteCallHistoryRecords(deleteSessionIDs []EndTimeSessionID) (*DeleteCallHistoryResponse, error)

DeleteCallHistoryRecords deletes call history records.

Parameters:

  • deleteSessionIDs: An array of EndTimeSessionID identifying the records to delete.

func (*CallHistoryClient) GetCallHistoryData

func (c *CallHistoryClient) GetCallHistoryData(days, limit int, sort Sort, sortBy SortBy) (*CallHistoryResponse, error)

GetCallHistoryData retrieves call history records based on specified parameters.

Parameters:

  • days: Number of days to fetch call history data for.
  • limit: Maximum number of records to fetch.
  • sort: Sort order (ASC or DESC).
  • sortBy: Field to sort by (endTime or startTime).

func (*CallHistoryClient) UpdateMissedCalls

func (c *CallHistoryClient) UpdateMissedCalls(endTimeSessionIDs []EndTimeSessionID) (*UpdateMissedCallsResponse, error)

UpdateMissedCalls updates the read state of missed calls.

Parameters:

  • endTimeSessionIDs: An array of EndTimeSessionID identifying the missed call records to mark as read.

type CallHistoryResponse

type CallHistoryResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		UserSessions []UserSession `json:"userSessions,omitempty"`
		Error        string        `json:"error,omitempty"`
	} `json:"data"`
}

CallHistoryResponse is the response from call history APIs

type CallRecordLink struct {
	LocusURL        string `json:"locusUrl,omitempty"`
	ConversationURL string `json:"conversationUrl,omitempty"`
	CallbackAddress string `json:"callbackAddress"`
}

CallRecordLink contains URLs associated with a call record

type CallRecordOther

type CallRecordOther struct {
	OwnerID                string `json:"ownerId,omitempty"`
	ID                     string `json:"id"`
	Name                   string `json:"name,omitempty"`
	SipURL                 string `json:"sipUrl,omitempty"`
	PrimaryDisplayString   string `json:"primaryDisplayString,omitempty"`
	SecondaryDisplayString string `json:"secondaryDisplayString,omitempty"`
	IsPrivate              bool   `json:"isPrivate"`
	CallbackAddress        string `json:"callbackAddress"`
	PhoneNumber            string `json:"phoneNumber,omitempty"`
	Contact                string `json:"contact,omitempty"`
	Email                  string `json:"email,omitempty"`
}

CallRecordOther represents the other party in a call record

type CallRecordSelf

type CallRecordSelf struct {
	ID            string `json:"id"`
	Name          string `json:"name,omitempty"`
	PhoneNumber   string `json:"phoneNumber,omitempty"`
	CucmDN        string `json:"cucmDN,omitempty"`
	UcmLineNumber int    `json:"ucmLineNumber,omitempty"`
}

CallRecordSelf represents the user's own info in a call record

type CallSettingResponse

type CallSettingResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		CallSetting interface{} `json:"callSetting,omitempty"`
		Error       string      `json:"error,omitempty"`
	} `json:"data"`
}

CallSettingResponse is the generic response from call settings APIs

type CallSettingsClient

type CallSettingsClient struct {
	// contains filtered or unexported fields
}

CallSettingsClient provides methods for retrieving and updating call settings such as Call Waiting, Do Not Disturb, Call Forwarding, and Voicemail configuration.

func (*CallSettingsClient) GetCallForwardAlwaysSetting

func (c *CallSettingsClient) GetCallForwardAlwaysSetting(directoryNumber string) (*CallSettingResponse, error)

GetCallForwardAlwaysSetting fetches the call forward always setting. The optional directoryNumber parameter is only required for CCUC backends.

func (*CallSettingsClient) GetCallForwardSetting

func (c *CallSettingsClient) GetCallForwardSetting() (*CallSettingResponse, error)

GetCallForwardSetting fetches the call forwarding settings.

func (*CallSettingsClient) GetCallWaitingSetting

func (c *CallSettingsClient) GetCallWaitingSetting() (*CallSettingResponse, error)

GetCallWaitingSetting fetches the call waiting setting for the authenticated user.

func (*CallSettingsClient) GetDoNotDisturbSetting

func (c *CallSettingsClient) GetDoNotDisturbSetting() (*CallSettingResponse, error)

GetDoNotDisturbSetting fetches the Do Not Disturb (DND) setting.

func (*CallSettingsClient) GetVoicemailSetting

func (c *CallSettingsClient) GetVoicemailSetting() (*CallSettingResponse, error)

GetVoicemailSetting fetches the voicemail settings.

func (*CallSettingsClient) SetCallForwardSetting

func (c *CallSettingsClient) SetCallForwardSetting(setting CallForwardSetting) (*CallSettingResponse, error)

SetCallForwardSetting updates the call forwarding settings.

func (*CallSettingsClient) SetDoNotDisturbSetting

func (c *CallSettingsClient) SetDoNotDisturbSetting(enabled bool) (*CallSettingResponse, error)

SetDoNotDisturbSetting enables or disables Do Not Disturb.

func (*CallSettingsClient) SetVoicemailSetting

func (c *CallSettingsClient) SetVoicemailSetting(setting VoicemailSettingConfig) (*CallSettingResponse, error)

SetVoicemailSetting updates the voicemail settings.

type CallState

type CallState string

CallState represents the state of a call in the state machine

const (
	CallStateIdle         CallState = "idle"
	CallStateProceeding   CallState = "proceeding"
	CallStateAlerting     CallState = "alerting"
	CallStateConnected    CallState = "connected"
	CallStateHeld         CallState = "held"
	CallStateDisconnected CallState = "disconnected"
)

type CallType

type CallType string

CallType indicates the type of call address

const (
	CallTypeURI CallType = "uri"
	CallTypeTEL CallType = "tel"
)

func NormalizeAddress

func NormalizeAddress(input string) (address string, callType CallType, err error)

NormalizeAddress normalizes a dial address for Mobius/BroadWorks:

  • SIP URIs (sip:/sips:) → passed through as-is with CallTypeURI
  • tel: URIs → passed through as-is with CallTypeURI
  • Phone numbers → sanitized and prefixed with "tel:" with CallTypeURI

Returns the normalized address, call type, and an error if the input is invalid. Matches the JS SDK's VALID_PHONE_REGEX /[\d\s()*#+.-]+/ behavior.

type CallerIDInfo

type CallerIDInfo struct {
	From                       string `json:"from,omitempty"`
	PAssertedIdentity          string `json:"p-asserted-identity,omitempty"`
	XBroadworksRemotePartyInfo string `json:"x-broadworks-remote-party-info,omitempty"`
}

CallerIDInfo contains caller identification info from Mobius

type CallingClient

type CallingClient struct {

	// Events
	Emitter *EventEmitter
	// contains filtered or unexported fields
}

CallingClient is the main orchestrator for Webex Calling call control. It manages line registration with Mobius servers, call creation, and incoming call handling via Mercury WebSocket events.

func NewCallingClient

func NewCallingClient(core *webexsdk.Client, config *Config, clientConfig *CallingClientConfig) *CallingClient

NewCallingClient creates a new CallingClient for managing lines and calls

func (*CallingClient) ClearAudioBridge

func (cc *CallingClient) ClearAudioBridge()

ClearAudioBridge removes the AudioBridge from this CallingClient.

func (*CallingClient) ConnectMercury

func (cc *CallingClient) ConnectMercury(merc *mercury.Client) error

ConnectMercury connects a Mercury WebSocket client and wires it to receive Mobius call events (ROAP answers, call progress, etc.). It uses the WDM WebSocket URL from line registration so events arrive on the correct device.

This is the idiomatic way to set up Mercury for calling — replaces the manual wildcard handler + event routing that consumers previously had to do.

func (*CallingClient) CreateLine

func (cc *CallingClient) CreateLine() (*Line, error)

CreateLine creates and registers a new line with the Mobius servers. Returns the Line object which can be used to make and receive calls.

func (*CallingClient) DeregisterAllDevices

func (cc *CallingClient) DeregisterAllDevices() (int, error)

DeregisterAllDevices attempts to deregister all existing Mobius devices for this user. It does this by attempting a registration POST — if a 403 errorCode 101 is returned, it extracts the existing device list and deletes each one.

func (*CallingClient) DisconnectMercury

func (cc *CallingClient) DisconnectMercury()

DisconnectMercury disconnects the Mercury WebSocket client if connected.

func (*CallingClient) DiscoverMobiusServers

func (cc *CallingClient) DiscoverMobiusServers() error

DiscoverMobiusServers discovers the Mobius servers for the user's region. It follows the same flow as the JS SDK:

  1. Register a WDM device to get clientDeviceUri and serviceHostMap (Mobius hosts)
  2. Get region info from the Webex region discovery service
  3. Query each Mobius host with region/country to get primary/backup URIs

func (*CallingClient) GetActiveCalls

func (cc *CallingClient) GetActiveCalls() map[string]*Call

GetActiveCalls returns all active calls

func (*CallingClient) GetAudioBridge

func (cc *CallingClient) GetAudioBridge() *AudioBridge

GetAudioBridge returns the currently registered AudioBridge, or nil.

func (*CallingClient) GetConnectedCall

func (cc *CallingClient) GetConnectedCall() *Call

GetConnectedCall returns the currently connected (not held) call, if any

func (*CallingClient) GetLines

func (cc *CallingClient) GetLines() map[string]*Line

GetLines returns all registered lines

func (*CallingClient) GetWDMWebSocketURL

func (cc *CallingClient) GetWDMWebSocketURL() string

GetWDMWebSocketURL returns the WebSocket URL from the WDM device registration. This should be used for Mercury connections to ensure events are received on the same device used for Mobius registration.

func (*CallingClient) HandleMercuryEvent

func (cc *CallingClient) HandleMercuryEvent(eventData []byte)

HandleMercuryEvent processes a Mercury WebSocket event that may contain Mobius call signaling data. This should be called when the Mercury client receives a "mobius" scoped event.

func (*CallingClient) IsMercuryConnected

func (cc *CallingClient) IsMercuryConnected() bool

IsMercuryConnected returns whether the Mercury client is connected.

func (*CallingClient) MakeCall

func (cc *CallingClient) MakeCall(line *Line, destination *CallDetails) (*Call, error)

MakeCall creates and dials an outbound call on the specified line

func (*CallingClient) SetAudioBridge

func (cc *CallingClient) SetAudioBridge(bridge *AudioBridge)

SetAudioBridge registers an AudioBridge with this CallingClient. When set, MakeCall() will automatically attach the bridge to new calls and detach it when calls disconnect. This eliminates manual bridge↔call wiring.

func (*CallingClient) SetMobiusServers

func (cc *CallingClient) SetMobiusServers(primary, backup []string)

SetMobiusServers manually sets the primary and backup Mobius server URLs

func (*CallingClient) Shutdown

func (cc *CallingClient) Shutdown() error

Shutdown deregisters all lines, disconnects Mercury, and cleans up resources

type CallingClientConfig

type CallingClientConfig struct {
	// ClientDeviceURI is the Webex device URL (from device registration)
	ClientDeviceURI string
	// MediaConfig is the WebRTC media configuration
	MediaConfig *MediaConfig
	// DiscoveryRegion overrides the region for Mobius server discovery
	DiscoveryRegion string
	// DiscoveryCountry overrides the country for Mobius server discovery
	DiscoveryCountry string
}

CallingClientConfig holds configuration for the CallingClient

type CallingSpecifics

type CallingSpecifics struct {
	RedirectionDetails RedirectionDetails `json:"redirectionDetails"`
}

CallingSpecifics contains calling-specific details for a session

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the top-level Calling client that aggregates all calling sub-clients.

func New

func New(core *webexsdk.Client, config *Config) *Client

New creates a new Calling client.

func (*Client) CallHistory

func (c *Client) CallHistory() *CallHistoryClient

CallHistory returns the Call History sub-client for retrieving and managing call history records.

func (*Client) CallSettings

func (c *Client) CallSettings() *CallSettingsClient

CallSettings returns the Call Settings sub-client for managing DND, call waiting, call forwarding, and voicemail settings.

func (*Client) CallingClient

func (c *Client) CallingClient(clientConfig *CallingClientConfig) *CallingClient

CallingClient returns the CallingClient sub-client for real-time call control (line registration, dial, answer, hold, transfer, DTMF) using Mobius signaling and Pion WebRTC for media.

func (*Client) Contacts

func (c *Client) Contacts() *ContactsClient

Contacts returns the Contacts sub-client for managing contacts and contact groups.

func (*Client) Voicemail

func (c *Client) Voicemail() *VoicemailClient

Voicemail returns the Voicemail sub-client for retrieving and managing voicemail messages.

type Config

type Config struct {
	// BaseURL overrides the default Webex API base URL (default: https://webexapis.com/v1)
	BaseURL string

	// RequestTimeout overrides the default HTTP request timeout
	RequestTimeout time.Duration

	// WDMURL is the Webex Device Management service URL used for Mobius discovery.
	// Default: https://wdm-a.wbx2.com/wdm/api/v1/devices
	WDMURL string

	// RegionDiscoveryURL is the URL for the Webex region discovery service.
	// Default: https://ds.ciscospark.com/v1/region
	RegionDiscoveryURL string
}

Config holds configuration for the Calling client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults

type Contact

type Contact struct {
	AddressInfo          *Address      `json:"addressInfo,omitempty"`
	AvatarURL            string        `json:"avatarURL,omitempty"`
	AvatarURLDomain      string        `json:"avatarUrlDomain,omitempty"`
	CompanyName          string        `json:"companyName,omitempty"`
	ContactID            string        `json:"contactId"`
	ContactType          ContactType   `json:"contactType"`
	Department           string        `json:"department,omitempty"`
	DisplayName          string        `json:"displayName,omitempty"`
	Emails               []URIAddress  `json:"emails,omitempty"`
	EncryptionKeyURL     string        `json:"encryptionKeyUrl"`
	FirstName            string        `json:"firstName,omitempty"`
	Groups               []string      `json:"groups"`
	KmsResourceObjectURL string        `json:"kmsResourceObjectUrl,omitempty"`
	LastName             string        `json:"lastName,omitempty"`
	Manager              string        `json:"manager,omitempty"`
	OwnerID              string        `json:"ownerId,omitempty"`
	PhoneNumbers         []PhoneNumber `json:"phoneNumbers,omitempty"`
	PrimaryContactMethod string        `json:"primaryContactMethod,omitempty"`
	Schemas              string        `json:"schemas,omitempty"`
	SipAddresses         []URIAddress  `json:"sipAddresses,omitempty"`
	Resolved             bool          `json:"resolved"`
}

Contact represents a single contact

type ContactGroup

type ContactGroup struct {
	DisplayName      string    `json:"displayName"`
	EncryptionKeyURL string    `json:"encryptionKeyUrl"`
	GroupID          string    `json:"groupId"`
	GroupType        GroupType `json:"groupType"`
	Members          []string  `json:"members,omitempty"`
	OwnerID          string    `json:"ownerId,omitempty"`
}

ContactGroup represents a contact group

type ContactResponse

type ContactResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		Contacts []Contact      `json:"contacts,omitempty"`
		Groups   []ContactGroup `json:"groups,omitempty"`
		Contact  *Contact       `json:"contact,omitempty"`
		Group    *ContactGroup  `json:"group,omitempty"`
		Error    string         `json:"error,omitempty"`
	} `json:"data"`
}

ContactResponse is the response from contacts APIs

type ContactType

type ContactType string

ContactType indicates whether a contact is custom or cloud-synced

const (
	ContactTypeCustom ContactType = "CUSTOM"
	ContactTypeCloud  ContactType = "CLOUD"
)

type ContactsClient

type ContactsClient struct {
	// contains filtered or unexported fields
}

ContactsClient provides methods for managing contacts and contact groups.

func (*ContactsClient) CreateContact

func (c *ContactsClient) CreateContact(contact Contact) (*ContactResponse, error)

CreateContact creates a new contact.

func (*ContactsClient) CreateContactGroup

func (c *ContactsClient) CreateContactGroup(displayName, encryptionKeyURL string, groupType GroupType) (*ContactResponse, error)

CreateContactGroup creates a new contact group with the given display name.

Parameters:

  • displayName: The name of the contact group.
  • encryptionKeyURL: Optional encryption key URL.
  • groupType: The type of group (NORMAL or EXTERNAL).

func (*ContactsClient) DeleteContact

func (c *ContactsClient) DeleteContact(contactID string) (*ContactResponse, error)

DeleteContact deletes a contact by its contactId.

func (*ContactsClient) DeleteContactGroup

func (c *ContactsClient) DeleteContactGroup(groupID string) (*ContactResponse, error)

DeleteContactGroup deletes a contact group by its groupId.

func (*ContactsClient) GetContacts

func (c *ContactsClient) GetContacts() (*ContactResponse, error)

GetContacts fetches the list of contacts and contact groups for the authenticated user.

type DeleteCallHistoryResponse

type DeleteCallHistoryResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		DeleteStatusMessage string `json:"deleteStatusMessage,omitempty"`
		Error               string `json:"error,omitempty"`
	} `json:"data"`
}

DeleteCallHistoryResponse is the response from deleting call history records

type DeviceType

type DeviceType struct {
	DeviceID        string   `json:"deviceId"`
	URI             string   `json:"uri"`
	Status          string   `json:"status"`
	LastSeen        string   `json:"lastSeen"`
	Addresses       []string `json:"addresses"`
	ClientDeviceURI string   `json:"clientDeviceUri"`
}

DeviceType represents a registered Mobius device

type DisconnectCode

type DisconnectCode int

DisconnectCode represents the reason code for a call disconnect

const (
	DisconnectCodeNormal          DisconnectCode = 0
	DisconnectCodeBusy            DisconnectCode = 115
	DisconnectCodeMediaInactivity DisconnectCode = 131
)

type DisconnectReason

type DisconnectReason struct {
	Code  DisconnectCode `json:"code"`
	Cause string         `json:"cause"`
}

DisconnectReason contains the code and cause for a call disconnect

type DisplayInformation

type DisplayInformation struct {
	AvatarSrc string `json:"avatarSrc,omitempty"`
	Name      string `json:"name,omitempty"`
	Num       string `json:"num,omitempty"`
	ID        string `json:"id,omitempty"`
}

DisplayInformation represents resolved caller/contact display info

type Disposition

type Disposition string

Disposition indicates the outcome of a call session

const (
	DispositionAnswered  Disposition = "Answered"
	DispositionCanceled  Disposition = "Canceled"
	DispositionInitiated Disposition = "Initiated"
	DispositionMissed    Disposition = "MISSED"
)

type EndTimeSessionID

type EndTimeSessionID struct {
	EndTime   string `json:"endTime"`
	SessionID string `json:"sessionId"`
}

EndTimeSessionID identifies a call history record by end time and session ID

type EventEmitter

type EventEmitter struct {
	// contains filtered or unexported fields
}

EventEmitter provides a simple event pub/sub system

func NewEventEmitter

func NewEventEmitter() *EventEmitter

NewEventEmitter creates a new EventEmitter

func (*EventEmitter) Emit

func (e *EventEmitter) Emit(event string, data interface{})

Emit fires an event, calling all registered handlers

func (*EventEmitter) Off

func (e *EventEmitter) Off(event string)

Off removes all handlers for a specific event type

func (*EventEmitter) On

func (e *EventEmitter) On(event string, handler EventHandler)

On registers an event handler for a specific event type

type EventHandler

type EventHandler func(data interface{})

EventHandler is a callback function for events

type GroupType

type GroupType string

GroupType indicates the type of contact group

const (
	GroupTypeNormal   GroupType = "NORMAL"
	GroupTypeExternal GroupType = "EXTERNAL"
)

type Line

type Line struct {

	// Line properties
	LineID         string
	UserID         string
	MobiusDeviceID string
	PhoneNumber    string
	Extension      string
	SipAddresses   []string
	Voicemail      string

	// Events
	Emitter *EventEmitter
	// contains filtered or unexported fields
}

Line represents a registered telephony line with a Mobius server. A line must be registered before calls can be made or received.

func NewLine

func NewLine(core *webexsdk.Client, config *Config, lineConfig *LineConfig) *Line

NewLine creates a new Line instance

func (*Line) Deregister

func (l *Line) Deregister() error

Deregister deregisters this line from the Mobius server

func (*Line) GetActiveMobiusURL

func (l *Line) GetActiveMobiusURL() string

GetActiveMobiusURL returns the active Mobius server URL

func (*Line) GetDeviceID

func (l *Line) GetDeviceID() string

GetDeviceID returns the Mobius device ID

func (*Line) GetDeviceInfo

func (l *Line) GetDeviceInfo() *MobiusDeviceInfo

GetDeviceInfo returns the device info from Mobius registration

func (*Line) GetStatus

func (l *Line) GetStatus() RegistrationStatus

GetStatus returns the current registration status

func (*Line) IsRegistered

func (l *Line) IsRegistered() bool

IsRegistered returns true if the line is currently registered

func (*Line) Register

func (l *Line) Register() error

Register registers this line with the Mobius server. It attempts primary servers first, then falls back to backup servers.

type LineConfig

type LineConfig struct {
	// PrimaryMobiusURLs is the list of primary Mobius server URLs
	PrimaryMobiusURLs []string
	// BackupMobiusURLs is the list of backup Mobius server URLs
	BackupMobiusURLs []string
	// ClientDeviceURI is the Webex device URL for this client
	ClientDeviceURI string
	// UserID is the Webex user ID (from device registration)
	UserID string
}

LineConfig holds configuration for creating a line

type LineEventKey

type LineEventKey string

LineEventKey identifies the type of line event

const (
	LineEventConnecting   LineEventKey = "connecting"
	LineEventRegistered   LineEventKey = "registered"
	LineEventUnregistered LineEventKey = "unregistered"
	LineEventReconnecting LineEventKey = "reconnecting"
	LineEventReconnected  LineEventKey = "reconnected"
	LineEventIncomingCall LineEventKey = "incoming_call"
	LineEventError        LineEventKey = "error"
)

type MediaConfig

type MediaConfig struct {
	// ICEServers is the list of ICE servers (STUN/TURN) to use
	ICEServers []webrtc.ICEServer
	// AudioCodecs is the list of audio codecs to use (default: opus, PCMU, PCMA)
	AudioCodecs []string
}

MediaConfig holds configuration for the media engine

func DefaultMediaConfig

func DefaultMediaConfig() *MediaConfig

DefaultMediaConfig returns a MediaConfig with sensible defaults. STUN is required because the Go server is typically behind NAT and BroadWorks (ice-lite) needs a public srflx candidate to reach us. The JS SDK uses iceServers:[] because the browser handles NAT traversal via ICE connectivity checks, but Pion needs an explicit public candidate.

type MediaEngine

type MediaEngine struct {
	// contains filtered or unexported fields
}

MediaEngine manages the WebRTC peer connection and media tracks for a call.

func NewMediaEngine

func NewMediaEngine(config *MediaConfig) (*MediaEngine, error)

NewMediaEngine creates a new WebRTC media engine for a call

func (*MediaEngine) AddAudioTrack

func (me *MediaEngine) AddAudioTrack() (*webrtc.TrackLocalStaticRTP, error)

AddAudioTrack adds a local audio track to the peer connection. Uses PCMU codec since BroadWorks/Mobius consistently selects it.

func (*MediaEngine) Close

func (me *MediaEngine) Close() error

Close closes the peer connection and releases resources

func (*MediaEngine) ConnectedCh

func (me *MediaEngine) ConnectedCh() <-chan struct{}

ConnectedCh returns a channel that is closed when the Mobius PC reaches connected state.

func (*MediaEngine) CreateAnswer

func (me *MediaEngine) CreateAnswer() (string, error)

CreateAnswer creates an SDP answer for the peer connection

func (*MediaEngine) CreateOffer

func (me *MediaEngine) CreateOffer() (string, error)

CreateOffer creates an SDP offer for the peer connection

func (*MediaEngine) GetConnectionState

func (me *MediaEngine) GetConnectionState() webrtc.PeerConnectionState

GetConnectionState returns the current peer connection state

func (*MediaEngine) GetLocalTrack

func (me *MediaEngine) GetLocalTrack() *webrtc.TrackLocalStaticRTP

GetLocalTrack returns the local audio track

func (*MediaEngine) GetPeerConnection

func (me *MediaEngine) GetPeerConnection() *webrtc.PeerConnection

GetPeerConnection returns the underlying Pion PeerConnection for advanced use (e.g. RTP relay)

func (*MediaEngine) GetRemoteTrack

func (me *MediaEngine) GetRemoteTrack() *webrtc.TrackRemote

GetRemoteTrack returns the remote audio track

func (*MediaEngine) IsConnected

func (me *MediaEngine) IsConnected() bool

IsConnected returns true if the Mobius PeerConnection is in the connected state.

func (*MediaEngine) IsMuted

func (me *MediaEngine) IsMuted() bool

IsMuted returns whether the local audio is muted

func (*MediaEngine) Mute

func (me *MediaEngine) Mute()

Mute disables the local audio track

func (*MediaEngine) OnICECandidate

func (me *MediaEngine) OnICECandidate(handler func(candidate *webrtc.ICECandidate))

OnICECandidate sets the callback for when an ICE candidate is gathered

func (*MediaEngine) OnRemoteTrack

func (me *MediaEngine) OnRemoteTrack(handler func(track *webrtc.TrackRemote))

OnRemoteTrack sets the callback for when a remote audio track is received

func (*MediaEngine) SetRemoteAnswer

func (me *MediaEngine) SetRemoteAnswer(sdp string) error

SetRemoteAnswer sets the remote SDP answer on the peer connection. If the PC is already in stable state (answer already applied), this is a no-op.

func (*MediaEngine) SetRemoteOffer

func (me *MediaEngine) SetRemoteOffer(sdp string) error

SetRemoteOffer sets the remote SDP offer on the peer connection

func (*MediaEngine) Unmute

func (me *MediaEngine) Unmute()

Unmute enables the local audio track

type MidCallEvent

type MidCallEvent struct {
	EventType string      `json:"eventType"`
	EventData interface{} `json:"eventData"`
}

MidCallEvent represents a mid-call event (e.g., hold state change)

type MobiusCallData

type MobiusCallData struct {
	CallProgressData *struct {
		Alerting    bool `json:"alerting"`
		InbandMedia bool `json:"inbandMedia"`
	} `json:"callProgressData,omitempty"`
	Message        *RoapMessage    `json:"message,omitempty"`
	CallerID       *CallerIDInfo   `json:"callerId,omitempty"`
	MidCallService []MidCallEvent  `json:"midCallService,omitempty"`
	CallID         string          `json:"callId"`
	CallURL        string          `json:"callUrl"`
	DeviceID       string          `json:"deviceId"`
	CorrelationID  string          `json:"correlationId"`
	EventType      MobiusEventType `json:"eventType"`
}

MobiusCallData represents the data payload in a Mobius call event

type MobiusCallEvent

type MobiusCallEvent struct {
	ID         string         `json:"id"`
	Data       MobiusCallData `json:"data"`
	Timestamp  int64          `json:"timestamp"`
	TrackingID string         `json:"trackingId"`
}

MobiusCallEvent is a full Mobius WebSocket event for calls

type MobiusCallResponse

type MobiusCallResponse struct {
	StatusCode int `json:"statusCode"`
	Body       struct {
		Device struct {
			DeviceID      string `json:"deviceId"`
			CorrelationID string `json:"correlationId"`
		} `json:"device"`
		CallID   string `json:"callId"`
		CallData *struct {
			CallState string `json:"callState"`
		} `json:"callData,omitempty"`
		LocalMedia *struct {
			Roap *RoapMessage `json:"roap,omitempty"`
		} `json:"localMedia,omitempty"`
	} `json:"body"`
}

MobiusCallResponse is the response from Mobius when creating a call

type MobiusDeviceInfo

type MobiusDeviceInfo struct {
	UserID                string      `json:"userId,omitempty"`
	Device                *DeviceType `json:"device,omitempty"`
	KeepaliveInterval     int         `json:"keepaliveInterval,omitempty"`
	CallKeepaliveInterval int         `json:"callKeepaliveInterval,omitempty"`
	VoicePortalNumber     int         `json:"voicePortalNumber,omitempty"`
	VoicePortalExtension  int         `json:"voicePortalExtension,omitempty"`
	RehomingIntervalMin   int         `json:"rehomingIntervalMin,omitempty"`
	RehomingIntervalMax   int         `json:"rehomingIntervalMax,omitempty"`
}

MobiusDeviceInfo represents device info returned from Mobius registration

type MobiusEventType

type MobiusEventType string

MobiusEventType identifies the type of Mobius WebSocket event

const (
	MobiusEventCallSetup        MobiusEventType = "mobius.call"
	MobiusEventCallProgress     MobiusEventType = "mobius.callprogress"
	MobiusEventCallConnected    MobiusEventType = "mobius.callconnected"
	MobiusEventCallMedia        MobiusEventType = "mobius.media"
	MobiusEventCallDisconnected MobiusEventType = "mobius.calldisconnected"
)

type PersonInfo

type PersonInfo struct {
	ID           string        `json:"id"`
	Emails       []string      `json:"emails"`
	PhoneNumbers []PhoneNumber `json:"phoneNumbers"`
	DisplayName  string        `json:"displayName"`
	NickName     string        `json:"nickName"`
	FirstName    string        `json:"firstName"`
	LastName     string        `json:"lastName"`
	Avatar       string        `json:"avatar"`
	OrgID        string        `json:"orgId"`
	Created      string        `json:"created"`
	LastModified string        `json:"lastModified"`
	LastActivity string        `json:"lastActivity"`
	Status       string        `json:"status"`
	Type         string        `json:"type"`
}

PersonInfo represents a Webex person

type PhoneNumber

type PhoneNumber struct {
	Type    string `json:"type"`
	Value   string `json:"value"`
	Primary *bool  `json:"primary,omitempty"`
}

PhoneNumber represents a phone number with type and primary flag

type RedirectionDetails

type RedirectionDetails struct {
	PhoneNumber string `json:"phoneNumber,omitempty"`
	SipURL      string `json:"sipUrl,omitempty"`
	Name        string `json:"name,omitempty"`
	Reason      string `json:"reason"`
	UserID      string `json:"userId,omitempty"`
	IsPrivate   bool   `json:"isPrivate"`
}

RedirectionDetails contains call redirection info

type RegistrationStatus

type RegistrationStatus string

RegistrationStatus represents the registration state of a line

const (
	RegistrationStatusIdle     RegistrationStatus = "IDLE"
	RegistrationStatusActive   RegistrationStatus = "active"
	RegistrationStatusInactive RegistrationStatus = "inactive"
)

type RoapMessage

type RoapMessage struct {
	Seq               int             `json:"seq"`
	MessageType       RoapMessageType `json:"messageType"`
	SDP               string          `json:"sdp,omitempty"`
	OffererSessionID  string          `json:"offererSessionId,omitempty"`
	AnswererSessionID string          `json:"answererSessionId,omitempty"`
	Version           string          `json:"version,omitempty"`
	TieBreaker        string          `json:"tieBreaker,omitempty"`
	ErrorType         string          `json:"errorType,omitempty"`
}

RoapMessage represents a ROAP signaling message exchanged with Mobius

func NewRoapOK

func NewRoapOK(seq int) *RoapMessage

NewRoapOK creates a ROAP OK message

func SDPToRoapAnswer

func SDPToRoapAnswer(sdp string, seq int) *RoapMessage

SDPToRoapAnswer wraps an SDP string into a ROAP ANSWER message

func SDPToRoapOffer

func SDPToRoapOffer(sdp string, seq int) *RoapMessage

SDPToRoapOffer wraps an SDP string into a ROAP OFFER message

type RoapMessageType

type RoapMessageType string

RoapMessageType identifies the type of ROAP message

const (
	RoapMessageOffer        RoapMessageType = "OFFER"
	RoapMessageAnswer       RoapMessageType = "ANSWER"
	RoapMessageOK           RoapMessageType = "OK"
	RoapMessageError        RoapMessageType = "ERROR"
	RoapMessageOfferRequest RoapMessageType = "OFFER_REQUEST"
)

type SessionType

type SessionType string

SessionType indicates the type of call session

const (
	SessionTypeSpark        SessionType = "SPARK"
	SessionTypeWebexCalling SessionType = "WEBEXCALLING"
)

type SignalingMessage

type SignalingMessage struct {
	Type      string          `json:"type"`
	SDP       string          `json:"sdp,omitempty"`
	Candidate json.RawMessage `json:"candidate,omitempty"`
}

SignalingMessage is the JSON structure exchanged between the AudioBridge and the browser for WebRTC signaling.

type SignalingTransport

type SignalingTransport interface {
	// ReadMessage blocks until a signaling message arrives from the browser.
	// Returns the raw JSON bytes or an error (e.g. connection closed).
	ReadMessage() ([]byte, error)

	// WriteMessage sends a signaling message to the browser.
	WriteMessage(data []byte) error
}

SignalingTransport is a transport-agnostic interface for exchanging WebRTC signaling messages (SDP offers/answers, ICE candidates) with a browser. Implement this over WebSocket, gRPC, HTTP polling, etc.

type Sort

type Sort string

Sort order for list queries

const (
	SortASC  Sort = "ASC"
	SortDESC Sort = "DESC"
)

type SortBy

type SortBy string

SortBy field for call history queries

const (
	SortByEndTime   SortBy = "endTime"
	SortByStartTime SortBy = "startTime"
)

type ToggleSetting

type ToggleSetting struct {
	Enabled           bool  `json:"enabled"`
	RingSplashEnabled *bool `json:"ringSplashEnabled,omitempty"`
}

ToggleSetting represents a simple on/off setting with optional ring splash

type TransferType

type TransferType string

TransferType indicates the type of call transfer

const (
	TransferTypeBlind   TransferType = "BLIND"
	TransferTypeConsult TransferType = "CONSULT"
)

type URIAddress

type URIAddress struct {
	Value   string `json:"value"`
	Type    string `json:"type"`
	Primary *bool  `json:"primary,omitempty"`
}

URIAddress represents a URI-based address (email, SIP, etc.)

type UpdateMissedCallsResponse

type UpdateMissedCallsResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		ReadStatusMessage string `json:"readStatusMessage,omitempty"`
		Error             string `json:"error,omitempty"`
	} `json:"data"`
}

UpdateMissedCallsResponse is the response from updating missed calls

type UserSession

type UserSession struct {
	ID                    string            `json:"id"`
	SessionID             string            `json:"sessionId"`
	Disposition           Disposition       `json:"disposition"`
	StartTime             string            `json:"startTime"`
	EndTime               string            `json:"endTime"`
	URL                   string            `json:"url"`
	DurationSeconds       int               `json:"durationSeconds"`
	JoinedDurationSeconds int               `json:"joinedDurationSeconds"`
	ParticipantCount      int               `json:"participantCount"`
	IsDeleted             bool              `json:"isDeleted"`
	IsPMR                 bool              `json:"isPMR"`
	CorrelationIDs        []string          `json:"correlationIds"`
	Links                 CallRecordLink    `json:"links"`
	Self                  CallRecordSelf    `json:"self"`
	DurationSecs          int               `json:"durationSecs"`
	Other                 CallRecordOther   `json:"other"`
	SessionType           SessionType       `json:"sessionType"`
	Direction             string            `json:"direction"`
	CallingSpecifics      *CallingSpecifics `json:"callingSpecifics,omitempty"`
}

UserSession represents a single call history record

type VoicemailCallingPartyInfo

type VoicemailCallingPartyInfo struct {
	Name           string `json:"name"`
	UserID         string `json:"userId,omitempty"`
	Address        string `json:"address"`
	UserExternalID string `json:"userExternalId,omitempty"`
}

VoicemailCallingPartyInfo represents the caller info for a voicemail

type VoicemailClient

type VoicemailClient struct {
	// contains filtered or unexported fields
}

VoicemailClient provides methods for retrieving and managing voicemail messages.

func (*VoicemailClient) Delete

func (c *VoicemailClient) Delete(messageID string) (*VoicemailResponse, error)

Delete deletes a voicemail message by its messageId.

func (*VoicemailClient) GetTranscript

func (c *VoicemailClient) GetTranscript(messageID string) (*VoicemailResponse, error)

GetTranscript retrieves the transcript of a voicemail message.

func (*VoicemailClient) GetVoicemailContent

func (c *VoicemailClient) GetVoicemailContent(messageID string) (*VoicemailResponse, error)

GetVoicemailContent retrieves the content of a voicemail message by its messageId.

func (*VoicemailClient) GetVoicemailList

func (c *VoicemailClient) GetVoicemailList(offset, offsetLimit int, sort Sort) (*VoicemailResponse, error)

GetVoicemailList retrieves a list of voicemails with pagination and sorting.

Parameters:

  • offset: Number of records to skip.
  • offsetLimit: Maximum number of voicemails to retrieve.
  • sort: Sort order (ASC or DESC).

func (*VoicemailClient) GetVoicemailSummary

func (c *VoicemailClient) GetVoicemailSummary() (*VoicemailResponse, error)

GetVoicemailSummary retrieves a quantitative summary of voicemails for the user.

func (*VoicemailClient) MarkAsRead

func (c *VoicemailClient) MarkAsRead(messageID string) (*VoicemailResponse, error)

MarkAsRead marks a voicemail message as read.

func (*VoicemailClient) MarkAsUnread

func (c *VoicemailClient) MarkAsUnread(messageID string) (*VoicemailResponse, error)

MarkAsUnread marks a voicemail message as unread.

type VoicemailContent

type VoicemailContent struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

VoicemailContent represents the content of a voicemail

type VoicemailMessage

type VoicemailMessage struct {
	MessageID        string                    `json:"messageId"`
	Duration         string                    `json:"duration"`
	CallingPartyInfo VoicemailCallingPartyInfo `json:"callingPartyInfo"`
	Time             int64                     `json:"time"`
	Read             bool                      `json:"read"`
}

VoicemailMessage represents a single voicemail message

type VoicemailResponse

type VoicemailResponse struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message,omitempty"`
	Data       struct {
		VoicemailList       []VoicemailMessage `json:"voicemailList,omitempty"`
		VoicemailContent    *VoicemailContent  `json:"voicemailContent,omitempty"`
		VoicemailSummary    *VoicemailSummary  `json:"voicemailSummary,omitempty"`
		VoicemailTranscript *string            `json:"voicemailTranscript,omitempty"`
		Error               string             `json:"error,omitempty"`
	} `json:"data"`
}

VoicemailResponse is the response from voicemail APIs

type VoicemailSettingConfig

type VoicemailSettingConfig struct {
	Enabled      bool `json:"enabled"`
	SendAllCalls *struct {
		Enabled bool `json:"enabled"`
	} `json:"sendAllCalls,omitempty"`
	SendBusyCalls struct {
		Enabled          bool   `json:"enabled"`
		Greeting         string `json:"greeting,omitempty"`
		GreetingUploaded *bool  `json:"greetingUploaded,omitempty"`
	} `json:"sendBusyCalls"`
	SendUnansweredCalls struct {
		Enabled                bool   `json:"enabled"`
		Greeting               string `json:"greeting,omitempty"`
		GreetingUploaded       *bool  `json:"greetingUploaded,omitempty"`
		NumberOfRings          int    `json:"numberOfRings"`
		SystemMaxNumberOfRings *int   `json:"systemMaxNumberOfRings,omitempty"`
	} `json:"sendUnansweredCalls"`
	Notifications struct {
		Enabled     bool   `json:"enabled"`
		Destination string `json:"destination,omitempty"`
	} `json:"notifications"`
	TransferToNumber *struct {
		Enabled     bool   `json:"enabled"`
		Destination string `json:"destination"`
	} `json:"transferToNumber,omitempty"`
	EmailCopyOfMessage struct {
		Enabled bool   `json:"enabled"`
		EmailID string `json:"emailId,omitempty"`
	} `json:"emailCopyOfMessage"`
	MessageStorage struct {
		MWIEnabled    bool   `json:"mwiEnabled"`
		StorageType   string `json:"storageType"`
		ExternalEmail string `json:"externalEmail,omitempty"`
	} `json:"messageStorage"`
	FaxMessage *struct {
		Enabled     bool   `json:"enabled"`
		PhoneNumber string `json:"phoneNumber,omitempty"`
		Extension   string `json:"extension,omitempty"`
	} `json:"faxMessage,omitempty"`
	VoiceMessageForwardingEnabled *bool `json:"voiceMessageForwardingEnabled,omitempty"`
}

VoicemailSettingConfig is the full voicemail configuration

type VoicemailSummary

type VoicemailSummary struct {
	NewMessages       int `json:"newMessages"`
	OldMessages       int `json:"oldMessages"`
	NewUrgentMessages int `json:"newUrgentMessages"`
	OldUrgentMessages int `json:"oldUrgentMessages"`
}

VoicemailSummary provides a count of voicemail messages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL