Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/RPCMessages/RPCConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export const DEFAULT_CONNECT_VERSION = {
major: 3,
minor: 0,
revision: 0,
string: 'bkw',
}

export const UNIFIED_CONNECT_VERSION = {
major: 4,
minor: 0,
revision: 0,
string: 'bkw',
}

export const RPCConnect = (params: RPCConnectParams) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "SignalWire JS SDK",
"author": "SignalWire Team <[email protected]>",
"license": "MIT",
"version": "3.29.1",
"version": "3.29.1-bkw",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "3.29.1-bkw",
"version": "3.29.1",

We use Changeset to manage dev releases; no need to add developer tags.

"main": "dist/index.js",
"module": "dist/index.esm.js",
"unpkg": "dist/index.umd.js",
Expand Down
15 changes: 15 additions & 0 deletions packages/js/src/fabric/WSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { PREVIOUS_CALLID_STORAGE_KEY } from './utils/constants'
export class WSClient extends BaseClient<{}> implements WSClientContract {
private _incomingCallManager: IncomingCallManager
private _disconnected: boolean = false
private _eventCleanup: Array<() => void> = []

constructor(private wsClientOptions: WSClientOptions) {
const client = createWSClient(wsClientOptions)
Expand Down Expand Up @@ -305,10 +306,24 @@ export class WSClient extends BaseClient<{}> implements WSClientContract {
this._disconnected = true
})

// Clean up all event listeners
this._cleanupEventListeners()

super.disconnect()
})
}

private _cleanupEventListeners() {
this._eventCleanup.forEach(cleanup => {
try {
cleanup()
} catch (error) {
this.logger.error('Error cleaning up event listener:', error)
}
})
this._eventCleanup = []
}

public async dial(params: DialParams) {
return new Promise<FabricRoomSession>(async (resolve, reject) => {
try {
Expand Down
25 changes: 17 additions & 8 deletions packages/js/src/fabric/workers/callSegmentWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const callSegmentWorker = function* (
case 'call.room':
cfRoomSession.emit(type, payload)
break
case 'call.state':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already being emitted in L#58 fabricWorker.ts

cfRoomSession.emit(type, payload)
break

/**
* The Core module includes a generic worker, {@link memberPositionWorker},
Expand Down Expand Up @@ -120,17 +123,23 @@ export const callSegmentWorker = function* (
}

const isSegmentEvent = (action: SDKActions) => {
const { type, payload } = action as FabricAction
const shouldWatch =
type.startsWith('call.') ||
type.startsWith('member.') ||
type.startsWith('layout.')
const { payload } = action as FabricAction

// Check both direct payload fields and nested params (for call.state events)
const hasSegmentCallId =
'call_id' in payload && segmentCallId === payload.call_id
('call_id' in payload && segmentCallId === payload.call_id) ||
('params' in payload &&
'call_id' in (payload as any).params &&
(payload as any).params.call_id === segmentCallId)

const hasSegmentRoomSessionId =
segmentRooSessionId === payload.room_session_id
(segmentRooSessionId === payload.room_session_id) ||
('params' in payload &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worker don't receive the raw payload from the WS instead it get a the params object already

'room_session_id' in (payload as any).params &&
(payload as any).params.room_session_id === segmentRooSessionId)

if (shouldWatch && (hasSegmentCallId || hasSegmentRoomSessionId)) {
// Allow ALL events that belong to this segment (no type filtering)
if (hasSegmentCallId || hasSegmentRoomSessionId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldWatch is required since we have other event workers each specialized in some set of events.

return true
}

Expand Down
Loading
Loading