-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import ConnectionBase from './base' | ||
|
||
/** | ||
* messaging_only 専用のクラス | ||
* 利用する場合は Sora 側での設定が必要 | ||
* Role は "sendonly" に固定される | ||
*/ | ||
export default class ConnectionMessaging extends ConnectionBase { | ||
/** | ||
* Sora へ接続するメソッド、legacyStream は利用できない | ||
* | ||
* @example | ||
* ```typescript | ||
* const messaging = connection.messaging("sora"); | ||
* await messaging.connect(); | ||
* ``` | ||
* | ||
* @public | ||
*/ | ||
async connect(): Promise<void> { | ||
// options が | ||
await Promise.race([ | ||
this.multiStream().finally(() => { | ||
this.clearConnectionTimeout() | ||
this.clearMonitorSignalingWebSocketEvent() | ||
}), | ||
this.setConnectionTimeout(), | ||
this.monitorSignalingWebSocketEvent(), | ||
]) | ||
this.monitorWebSocketEvent() | ||
this.monitorPeerConnectionState() | ||
} | ||
|
||
/** | ||
* マルチストリームで Sora へ接続するメソッド | ||
*/ | ||
private async multiStream(): Promise<void> { | ||
await this.disconnect() | ||
const ws = await this.getSignalingWebSocket(this.signalingUrlCandidates) | ||
const signalingMessage = await this.signaling(ws) | ||
await this.connectPeerConnection(signalingMessage) | ||
await this.setRemoteDescription(signalingMessage) | ||
await this.createAnswer(signalingMessage) | ||
this.sendAnswer() | ||
await this.onIceCandidate() | ||
await this.waitChangeConnectionStateConnected() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters