niravcodes
released this
06 Jun 11:59
·
63 commits
to main
since this release
Summary
This release brings significant enhancements and new features to the SignalWireClient, focusing on improved video handling, expanded API capabilities, and better user management:
-
Video Handling:
- New
buildVideoElement
function to easily create and manage video elements for calls and rooms. - Video streams now automatically adjust to occupy the full width of the specified container.
- New
-
Enhanced API Capabilities:
- Added methods for managing addresses and conversations, including fetching details, sending messages, and subscribing to updates.
- New functionality to handle user variables when dialing calls, enabling more personalized and detailed session information.
-
User Management:
- Introduced methods to get subscriber info and manage WebRTC endpoints' online/offline status.
-
Unified Notifications:
- Unified approach for handling incoming call notifications via WebSocket and Push Notification, simplifying the development process.
-
Improved Flexibility:
- Options to specify video/audio constraints while making calls, allowing for more customized call setups.
These updates collectively aim to provide a more flexible, powerful, and user-friendly experience for developers using the SignalWireClient.
Added
userVariables
param added when dialing a Fabric call
const client = await SignalWire({
host: ...
token: ...,
})
const call = await client.dial({
...params,
rootElement: document.getElementById('rootElement'),
userVariables: {
"name": "John Doe",
"email": "[email protected]",
//...
"fullBrowserVersion": "125.0.0.0",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
}
})
2. buildVideoElement
function that creates and optionally injects a video DOM element for a given Call
or Room
object
const call = await client.dial({
// ...
})
await call.start();
const { element, unsubscribe } = await buildVideoElement({
room: call,
})
const container = document.getElementById('container');
container.appendChild(element)
Or, to also implicitly inject the video DOM element into your chosen container:
const { element, unsubscribe } = await buildVideoElement({
room: call,
rootElement: document.getElementById('container'),
})
getAddress
method added to theaddress
namespace inSignalWireClient
which returns the details about a particular address id
client.address.getAddress({id: <address_id_to_fetch_details>})
getConversations
,getConversationMessages
,createConversationMessage
methods added to theconversation
namespace inSignalWireClient
const conversations = await client.conversation.getConversations()
const conversationMessages = await client.conversation.getConversationMessages({ addressId: '...' })
// Subscribe to updates
client.conversation.subscribeToUpdates((newConversation) => {
console.log('>> newConversation', newConversation)
})
SignalWireClient.getSubscriberInfo
method returns the info about the current subscriber
const subscriber = await client.getSubscriberInfo()
online
andoffline
methods added toSignalWireClient
to register/unregister the WebRTC endpoint
await client.online()
//or
await client.offline()
sendMessage
andgetMessages
methods added to theconversation
namespace
const result = await client.conversation.getConversations();
const convo = result.data.filter(c => c.id == <address_id>)[0];
convo.sendMessage({
text: 'hello world~',
})
await convo.getMessages()
- Ability to specify page size when querying for the
conversation
and theaddress
namespace
await client.conversation.getConversations({ pageSize: 10 });
await client.conversation.getMessages({ pageSize: 10 });
await client.conversation.getConversationMessages({ pageSize: 10 });
const addressData = await client.address.getAddresses({
type: 'room',
displayName: 'john doe',
pageSize: 10
})
Changed
- The video stream will occupy the full width of the
rootElement
container (breaking)
- Handling notifications of incoming calls via both WebSocket and Push Notification is now unified (breaking)
// register invitation callback for push notification only
client.online({pushNotification: __incomingCallNotification})
// register invitation callback for both push notification and websocket
client.online({all: __incomingCallNotification})
//accept call using the invite notification
function __incomingCallNotification(invite){
const call = await invite.accept(document.getElementById('rootElement'))
}
- Both
SignalWireClient.dial
andCallInvite.accept
methods now accept an optionalrootElement
parameter to specify where to put the video stream
invite.accept(document.getElementById('rootElement'))
const call = await client.dial({
// ...
rootElement: document.getElementById('rootElement')
});
member.joined
event now emitted for all members in acall.joined
event
- Users can now pass video/audio constraints while making a call.
const call = await client.dial({
to: "/public/some_resource",
video: false, // boolean | MediaTrackConstraints
audio: true, // boolean | MediaTrackConstraints
})