diff --git a/.vscode/settings.json b/.vscode/settings.json index 44aeb40..06a83ff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "typescript.tsdk": "node_modules\\typescript\\lib" + "typescript.tsdk": "node_modules\\typescript\\lib", + "deepscan.enable": true } diff --git a/CHANGELOG.md b/CHANGELOG.md index 56a38a3..a447717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.2.3 + +- This is a bogus release only to test if package publishing still works + ## 0.2.2 - Fix broken `AuthPersonalCredentials` import diff --git a/package.json b/package.json index 81b6a73..38a153c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parsec-sdk", - "version": "0.2.2", + "version": "0.2.3", "description": "UNOFFICIAL and WIP JavaScript/TypeScript SDK for Parsec remote desktop.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/classes/Client.ts b/src/classes/Client.ts index 9ba6770..070b117 100644 --- a/src/classes/Client.ts +++ b/src/classes/Client.ts @@ -22,6 +22,10 @@ export class Client { public peerID?: string; + private webrtcPeerConnection?: RTCPeerConnection; + + private websocket!: WebSocket; + /** * Authenticate client using the _personal_ strategy * @@ -89,4 +93,36 @@ export class Client { throw new Error(httpErrorBody?.error || (error as Error).message); } } + /** + * @param {{htmlVideo:HTMLVideoElement;htmlAudio:HTMLAudioElement;secret?:string;}} config + */ + public async connect(config: { + htmlVideo: HTMLVideoElement; + htmlAudio: HTMLAudioElement; + secret?: string; + }) { + if (!this.sessionID) { + throw new AuthRequiredError(); + } + + this.websocket = new WebSocket( + `wss://kessel-ws.parsecgaming.com:443/?session_id=${this.sessionID}&role=client&version=1&sdk_version=0` + ); + + this.websocket.onclose; + + this.webrtcPeerConnection = new RTCPeerConnection({ + iceServers: [{ urls: 'stun:stun.parsec.gg:3478' }] + }); + + this.webrtcPeerConnection.onicecandidate = ({ candidate }) => { + const iceCandidateData = candidate?.candidate + ?.replace('candidate:', '') + .split(' '); + + if (iceCandidateData && iceCandidateData.length >= 8) { + const protocol = iceCandidateData[2].toLowerCase(); + } + }; + } }