Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Call Fabric SDK #983

Merged
merged 29 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b0c7fa9
Refactor Call Fabric SDK
iAmmar7 Mar 12, 2024
55987e9
member instance of call.joined event
iAmmar7 Mar 13, 2024
712e79b
fix member instance storing
iAmmar7 Mar 13, 2024
d22f3f2
merge with dev
iAmmar7 Mar 13, 2024
ee57d67
fix call.mute api call
iAmmar7 Mar 13, 2024
b5bdc52
introduce call segments
iAmmar7 Mar 14, 2024
b0c38a9
remove member instance creation from room subscribed worker
iAmmar7 Mar 14, 2024
ee5e76d
build fix
iAmmar7 Mar 14, 2024
59745a6
include changeset
iAmmar7 Mar 14, 2024
8814f68
call fabric types file renamed
iAmmar7 Mar 14, 2024
94b2570
merge with dev
iAmmar7 Mar 19, 2024
f0cc6f9
merge with dev
iAmmar7 Mar 26, 2024
76d02b9
fix run worker
iAmmar7 Mar 26, 2024
84d24e4
consistent member id
iAmmar7 Mar 26, 2024
d29203c
consistent self member event
iAmmar7 Mar 26, 2024
b73da92
removed wrong member types
iAmmar7 Mar 27, 2024
33aa371
call fabric worker refactor
iAmmar7 Mar 28, 2024
a7b0e42
emit layout changed event
iAmmar7 Mar 29, 2024
6577236
video mute and unmute API integration with call fabric
iAmmar7 Mar 29, 2024
967bcdd
emit call.joined
iAmmar7 Apr 1, 2024
f7e571f
ts typings for call.left event
iAmmar7 Apr 1, 2024
d79917d
vide member worker types update
iAmmar7 Apr 1, 2024
9714427
refactor member action calling
iAmmar7 Apr 1, 2024
bc00992
more methods include
iAmmar7 Apr 2, 2024
2e4ec2c
merge with dev
iAmmar7 Apr 4, 2024
458765b
fix conversation unit tests
iAmmar7 Apr 4, 2024
5a8a566
remove undefined var
iAmmar7 Apr 4, 2024
854f67f
fix e2e tests
iAmmar7 Apr 4, 2024
8822391
fix unit tests
iAmmar7 Apr 4, 2024
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
7 changes: 7 additions & 0 deletions .changeset/slimy-seas-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@signalwire/webrtc': patch
'@signalwire/core': patch
'@signalwire/js': patch
---

Introduce CallSegment and CallFabric worker
2 changes: 2 additions & 0 deletions internal/e2e-js/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const reattachTests = [
'roomSessionReattachWrongProtocol.spec.ts',
]
const callfabricTests = [
'address.spec.ts',
'conversation.spec.ts',
'relayApp.spec.ts',
'swml.spec.ts',
'videoRoom.spec.ts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { SERVER_URL, createCFClient } from '../../utils'

test.describe('Addresses', () => {
test('query multiple addresses and single address', async ({
createCustomVanillaPage,
createCustomPage,
}) => {
const page = await createCustomVanillaPage({ name: '[page]' })
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

await createCFClient(page)
Expand All @@ -17,7 +17,9 @@ test.describe('Addresses', () => {
const response = await client.address.getAddresses()
const addressToCompare = response.data[0]

const address = await client.address.getAddress({ id: addressToCompare.id })
const address = await client.address.getAddress({
id: addressToCompare.id,
})
return { address, addressToCompare }
})

Expand Down
121 changes: 121 additions & 0 deletions internal/e2e-js/tests/callfabric/conversation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { SignalWireContract } from '@signalwire/js'
import { test, expect } from '../../fixtures'
import { SERVER_URL, createVideoRoom, createCFClient } from '../../utils'
import { uuid } from '@signalwire/core'

test.describe('Conversation Room', () => {
test('send message in a room conversation', async ({ createCustomPage }) => {
const page = await createCustomPage({ name: '[page]' })
const page2 = await createCustomPage({
name: '[page2]',
})
await page.goto(SERVER_URL)
await page2.goto(SERVER_URL)

await createCFClient(page)
await createCFClient(page2)

const roomName = `e2e-js-convo-room_${uuid()}`
await createVideoRoom(roomName)

const firstMsgEvent = await page.evaluate(
({ roomName }) => {
return new Promise(async (resolve) => {
// @ts-expect-error
const client = window._client as SignalWireContract
const addresses = await client.address.getAddresses({
displayName: roomName,
})
const roomAddress = addresses.data[0]
const addressId = roomAddress.id
client.conversation.subscribe(resolve)
client.conversation.sendMessage({
text: '1st message from 1st subscriber',
addressId,
})
})
},
{ roomName }
)

// @ts-expect-error
expect(firstMsgEvent.type).toBe('message')

// @ts-expect-error
const addressId = firstMsgEvent.address_id

const secondMsgEventPromiseFromPage1 = page.evaluate(() => {
return new Promise((resolve) => {
// @ts-expect-error
const client = window._client
client.conversation.subscribe(resolve)
})
})

const firstMsgEventFromPage2 = await page2.evaluate(
({ addressId }) => {
return new Promise(async (resolve) => {
// @ts-expect-error
const client = window._client as SignalWireContract
await client.connect()
client.conversation.subscribe(resolve)
const result = await client.conversation.getConversations()
const convo = result.data.filter((c) => c.id == addressId)[0]
convo.sendMessage({
text: '1st message from 2nd subscriber',
})
})
},
{ addressId }
)

const secondMsgEventFromPage1 = await secondMsgEventPromiseFromPage1
expect(secondMsgEventFromPage1).not.toBeUndefined()

// @ts-expect-error
expect(secondMsgEventFromPage1.type).toBe('message')

expect(firstMsgEventFromPage2).not.toBeUndefined()

// @ts-expect-error
expect(firstMsgEventFromPage2.type).toBe('message')

const messages = await page.evaluate(
async ({ addressId }) => {
// @ts-expect-error
const client = window._client as SignalWireContract
const result = await client.conversation.getConversations()
const convo = result.data.filter((c) => c.id == addressId)[0]
return await convo.getMessages({})
},
{ addressId }
)

expect(messages).not.toBeUndefined()

expect(messages.data.length).toEqual(2)
expect(messages.data[0]).toMatchObject({
conversation_id: addressId,
details: {},
id: expect.anything(),
kind: null,
subtype: 'chat',
text: '1st message from 2nd subscriber',
ts: expect.anything(),
type: 'message',
user_id: expect.anything(),
})

expect(messages.data[1]).toMatchObject({
conversation_id: addressId,
details: {},
id: expect.anything(),
kind: null,
subtype: 'chat',
text: '1st message from 1st subscriber',
ts: expect.anything(),
type: 'message',
user_id: expect.anything(),
})
})
})
116 changes: 0 additions & 116 deletions internal/e2e-js/tests/callfabric/conversationRoom.spec.ts

This file was deleted.

8 changes: 3 additions & 5 deletions internal/e2e-js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export const createTestRoomSessionWithJWT = async (
)
}

export const createCFClient = async (page: Page, sat?: string) => {
if (!sat) sat = await createTestSATToken()
export const createCFClient = async (page: Page) => {
const sat = await createTestSATToken()
if (!sat) {
console.error('Invalid SAT. Exiting..')
process.exit(4)
Expand Down Expand Up @@ -279,13 +279,11 @@ export const createTestSATToken = async () => {
}),
}
)
console.log(response.body.read().toString())
const data = await response.json()
return data.token
}


export const createVideoRoom= async (name?: string) => {
export const createVideoRoom = async (name?: string) => {
const response = await fetch(
`https://${process.env.API_HOST}/api/fabric/resources/video_rooms`,
{
Expand Down
Loading
Loading