-
Notifications
You must be signed in to change notification settings - Fork 53
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
docs(video): update push video docs #858
Conversation
madhur-push
commented
Nov 20, 2023
- Update video docs
- Minor: Fix param type of disconnect method
@madhur-push want to know if anyone is using this disconnect extensively, since this is a breaking change. |
@Aman035 I have revert the removal of null from disconnect options type. |
File: .husky/pre-commit
All looks good. File: packages/examples/sdk-frontend/package.json
There is a missing comma (
File: packages/restapi/README.md
File: packages/restapi/src/lib/video/Video.ts
Overall, there are several small issues in the code and comments that need to be fixed:
|
.husky/pre-commit
Outdated
# yarn nx affected --target=test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be commited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. 😅 Will do.
File: .husky/pre-commit #!/bin/sh
. "$(dirname "$0")/_/husky.sh"
echo "\nRunning GIT hooks..."
yarn cleanbuild
yarn nx affected --target=lint
yarn nx affected --target=test
File: packages/examples/sdk-frontend/package.json {
"name": "push-video-sdk-demo",
"private": true,
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@pushprotocol/restapi": "^1.4.39",
"@pushprotocol/socket": "^0.5.1",
"@pushprotocol/uiweb": "^1.1.8",
"@rainbow-me/rainbowkit": "0.12.14",
"ethers": "^5",
"immer": "^10.0.2",
"next": "^13.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styled-components": "^5.3.11",
"wagmi": "0.12.13"
},
"devDependencies": {
"@types/node": "^18.16.12",
"@types/react": "^18.2.6",
"@types/styled-components": "^5.1.26",
"eslint": "^8.15.0",
"eslint-config-next": "^13.4.3",
"typescript": "^5.0.4"
}
}
File: packages/restapi/README.md
File: packages/restapi/src/lib/video/Video.ts
Updated code: ...
getData(): VideoCallData {
return this.data;
}
setData(fn: (data: VideoCallData) => VideoCallData): void {
this.data = fn(this.data);
}
...
connect(options: VideoConnectInputOptions): void {
const { signalData, peerAddress } = options;
try {
console.log('Connecting to peer');
this.peerInstances[peerAddress ? peerAddress : this.data.incoming[0].address]?.on('error', (err) => {
console.log('error in connect', err);
const incomingIndex = peerAddress
? getIncomingIndexFromAddress(this.data.incoming, peerAddress)
: 0;
if (this.data.incoming[incomingIndex].retryCount >= 5) {
console.log('Max retries exceeded, please try again.');
this.disconnect({
peerAddress: peerAddress
? peerAddress
: this.data.incoming[0].address,
});
}
// retrying in case of connection error
this.request({
senderAddress: this.data.local.address,
recipientAddress: this.data.incoming[incomingIndex].address,
chatId: this.data.meta.chatId,
retry: true,
});
});
this.peerInstances[
peerAddress ? peerAddress : this.data.incoming[0].address
]?.signal(signalData);
// set videoCallInfo state with status connected for the caller's end
this.setData((oldData) => {
return produce(oldData, (draft) => {
const incomingIndex = peerAddress
? getIncomingIndexFromAddress(oldData.incoming, peerAddress)
: 0;
draft.incoming[incomingIndex].status = VideoCallStatus.CONNECTED;
});
});
} catch (err) {
console.log('error in connect', err);
}
}
disconnect(options?: VideoDisconnectOptions): void {
const { peerAddress, details } = options || {};
try {
console.log(
'DISCONNECT OPTIONS',
options,
'default',
this.data.incoming[0].address
);
if (!options?.peerAddress) {
console.warn('disconnect requires a peer address');
}
const incomingIndex = peerAddress
? getIncomingIndexFromAddress(this.data.incoming, peerAddress)
: 0;
console.log(
'disconnect',
'options',
'status',
this.data.incoming[incomingIndex]?.status
);
if (
this.data.incoming[incomingIndex].status === VideoCallStatus.CONNECTED
) {
this.peerInstances[
peerAddress ? peerAddress : this.data.incoming[0].address
]?.send(JSON.stringify({ type: 'endCall', value: true, details }));
}
this.peerInstances[
peerAddress ? peerAddress : this.data.incoming[0].address
]?.destroy();
} catch (err) {
console.log('error in disconnect', err);
}
}
...
|