Class Spaces
X スペースのすべての操作の入り口(Spaces)。
public sealed class Spaces
- Inheritance
-
Spaces
- Inherited Members
Remarks
メタデータ / 検索 — GraphQL(AudioSpaceById、AudioSpaceSearch、BrowseSpaceTopics、...)。 ブロードキャストのライフサイクル — proxsee.pscp.tv(Periscope)v2 API。 コントロールプレーン(ミュート、設定、終了、承認 ...)— guest-cf.pscp.tv /api/v1(chatman)。 チャット — proxsee accessChat → chatapi v1(HTTP 履歴 + WebSocket)。 音声(発言・聴取)— Janus WebRTC videoroom。ピア接続は IPeerConnectionFactory の実装が必要です。
API キーは不要で、twikit の他の機能と同じ Cookie 認証のセッションを使います。
Constructors
Spaces(Client)
public Spaces(Client client)
Parameters
clientClient
Properties
Chatman
chatman コントロールプレーン。
public ChatmanApi Chatman { get; }
Property Value
Proxsee
Periscope(proxsee)API。
public ProxseeApi Proxsee { get; }
Property Value
Methods
AddAdminAsync(string, string)
参加者を共同ホストにします。
public Task<JsonObject> AddAdminAsync(string spaceId, string userId)
Parameters
Returns
AddSharingAsync(string, string)
スペースにツイートを共有します。
public Task AddSharingAsync(string spaceId, string tweetId)
Parameters
Returns
ApproveAsync(string, string?)
発言リクエストを承認します。spaceId を渡すと chatman の初期化も行います。
public Task ApproveAsync(string sessionUuid, string? spaceId = null)
Parameters
Returns
AssociateTweetWithBroadcastAsync(string, string, bool)
ツイートをブロードキャストに関連付けます(proxsee associateTweetWithBroadcast)。
public Task<JsonObject> AssociateTweetWithBroadcastAsync(string spaceId, string tweetId, bool tweetExternal = false)
Parameters
Returns
CancelScheduledSpaceAsync(string)
public Task CancelScheduledSpaceAsync(string broadcastId)
Parameters
broadcastIdstring
Returns
CancelSpeakerRequestAsync(string, string)
保留中の発言リクエストを取り下げます。
public Task<JsonObject> CancelSpeakerRequestAsync(string spaceId, string sessionUuid)
Parameters
Returns
ChatAsync(string)
public Task<SpaceChat> ChatAsync(string spaceId)
Parameters
spaceIdstring
Returns
ChatAsync(Space)
スペースのチャットセッション(履歴 + 任意の WebSocket)を取得します。
public Task<SpaceChat> ChatAsync(Space space)
Parameters
spaceSpace
Returns
Close()
内部の HTTP クライアントを閉じます。
public void Close()
CreateSpaceAsync(string, string, JsonArray?, int, int, bool, bool, long, JsonArray?, string, JsonObject?, bool, JsonObject?)
スペースを作成します。proxsee の createBroadcast レスポンス(broadcast.id、access_token、room_id、 stream_name、credential、webrtc_gw_url など)を返します。
public Task<JsonObject> CreateSpaceAsync(string title = "", string description = "", JsonArray? topics = null, int conversationControls = 2, int narrowCastSpaceType = 0, bool isSpaceAvailableForReplay = false, bool isSpaceAvailableForClipping = false, long scheduledStartTime = 0, JsonArray? languages = null, string region = "us-west-1", JsonObject? extraMetadata = null, bool autoPublish = true, JsonObject? publishExtra = null)
Parameters
titlestringタイトル。
descriptionstring説明。
topicsJsonArrayトピック。
conversationControlsint発言できる相手(0=リクエスト/承認、1=フォロー中、2=全員)。
narrowCastSpaceTypeint0=全員、1=従業員、2=サブスクライバー。
isSpaceAvailableForReplayboolリプレイを残すか。
isSpaceAvailableForClippingboolクリップを許可するか。
scheduledStartTimelong予約開始時刻(エポックミリ秒。10^12 未満は秒として扱い変換します)。
languagesJsonArray言語。
regionstringリージョン。
extraMetadataJsonObject追加のメタデータ。
autoPublishbool作成後すぐに公開するか。
publishExtraJsonObjectpublishBroadcast に追加するペイロード。
Returns
DeleteSharingAsync(string, string)
スペースからツイートの共有を削除します。
public Task DeleteSharingAsync(string spaceId, string sharingId)
Parameters
Returns
EndSpaceAsync(string)
スペースを終了します。chatman で audiospace を終了し、proxsee でブロードキャストを落とします。
spaceId は proxsee の broadcast id(create_space の戻り値)または X のスペース ID。
public Task EndSpaceAsync(string spaceId)
Parameters
spaceIdstring
Returns
GetCallStatusAsync(string)
call/status のスナップショット(guest_sessions、states、...)を取得します。
public Task<JsonObject> GetCallStatusAsync(string spaceId)
Parameters
spaceIdstring
Returns
GetScheduledSpacesAsync()
予約済みのスペースを一覧します(各要素は broadcast 情報: id、state='NOT_STARTED'、scheduled_start、media_key、...)。
public Task<List<JsonObject>> GetScheduledSpacesAsync()
Returns
GetSpaceAsync(string, bool, bool)
13 文字の ID(または URL 全体)でスペースのメタデータを取得します。
public Task<Space> GetSpaceAsync(string spaceId, bool withReplays = true, bool withListeners = true)
Parameters
Returns
GetSpaceByUrlAsync(string, bool, bool)
public Task<Space> GetSpaceByUrlAsync(string url, bool withReplays = true, bool withListeners = true)
Parameters
Returns
GetStreamAsync(string)
media_key からストリーム情報(HLS URL とチャットトークン)を取得します。
public Task<SpaceStream> GetStreamAsync(string mediaKey)
Parameters
mediaKeystring
Returns
HostAsync(JsonObject, object, IPeerConnectionFactory, IReadOnlyList<IceServer>?, JsonObject?)
CreateSpaceAsync(string, string, JsonArray?, int, int, bool, bool, long, JsonArray?, string, JsonObject?, bool, JsonObject?) で作ったスペースのホスト音声セッションを開きます。
public Task<SpaceVoiceSession> HostAsync(JsonObject created, object audioTrack, IPeerConnectionFactory peerConnectionFactory, IReadOnlyList<IceServer>? iceServers = null, JsonObject? publishExtra = null)
Parameters
createdJsonObjectaudioTrackobject送信する音声トラック。
peerConnectionFactoryIPeerConnectionFactoryピア接続のファクトリ。
iceServersIReadOnlyList<IceServer>ICE サーバー。
publishExtraJsonObjectpublishBroadcast に追加するペイロード。
Returns
JoinAsync(string, bool, bool, bool)
public Task<JsonObject> JoinAsync(string spaceId, bool asSpeaker = false, bool joinAsAdmin = false, bool shouldAutoJoin = true)
Parameters
Returns
JoinAsync(Space, bool, bool, bool)
スピーカーまたはリスナーとしてスペースに参加します。chatman audiospace/join の {session_uuid, can_auto_join, ...} を返します。
public Task<JsonObject> JoinAsync(Space space, bool asSpeaker = false, bool joinAsAdmin = false, bool shouldAutoJoin = true)
Parameters
Returns
ListenAsync(Space, IPeerConnectionFactory, Action<object>?, IReadOnlyList<IceServer>?, int)
リスナーとして参加し、WebRTC の受信セッションを開きます(IPeerConnectionFactory が必要)。 より簡単に聴くには StreamUrlAsync(Space) の HLS URL を ffmpeg などで再生してください。
public Task<SpaceVoiceSession> ListenAsync(Space space, IPeerConnectionFactory peerConnectionFactory, Action<object>? onAudioTrack = null, IReadOnlyList<IceServer>? iceServers = null, int attempts = 3)
Parameters
spaceSpacepeerConnectionFactoryIPeerConnectionFactoryonAudioTrackAction<object>iceServersIReadOnlyList<IceServer>attemptsint
Returns
LowerHandAsync(string, string)
public Task<JsonObject> LowerHandAsync(string spaceId, string sessionUuid)
Parameters
Returns
MuteSpaceAsync(string)
スペース全体をミュートします(ホストのみ)。
public Task<JsonObject> MuteSpaceAsync(string spaceId)
Parameters
spaceIdstring
Returns
MuteSpeakerAsync(string, string)
public Task<JsonObject> MuteSpeakerAsync(string spaceId, string sessionUuid)
Parameters
Returns
RaiseHandAsync(string, string)
public Task<JsonObject> RaiseHandAsync(string spaceId, string sessionUuid)
Parameters
Returns
RejectAsync(string, string?)
発言リクエストを却下します。
public Task RejectAsync(string sessionUuid, string? spaceId = null)
Parameters
Returns
RemoveAdminAsync(string, string, string)
共同ホストを通常の参加者に戻します。
public Task<JsonObject> RemoveAdminAsync(string spaceId, string userId, string sessionUuid = "")
Parameters
Returns
RemoveParticipantAsync(string, IEnumerable<string>)
public Task<JsonObject> RemoveParticipantAsync(string spaceId, IEnumerable<string> userIds)
Parameters
spaceIdstringuserIdsIEnumerable<string>
Returns
RequestToSpeakAsync(string)
public Task<string> RequestToSpeakAsync(string spaceId)
Parameters
spaceIdstring
Returns
RequestToSpeakAsync(Space)
リスナーとして参加したスペースで発言をリクエストします。ホストが ApproveAsync(string, string?) で承認する session_uuid を返します。
public Task<string> RequestToSpeakAsync(Space space)
Parameters
spaceSpace
Returns
SearchAsync(string, string, bool)
スペースを検索します。filter は 'Top'、'Live'、'Upcoming'。
X の検索ペイロードには各スペースの rest_id しか無いため、既定では GetSpaceAsync(string, bool, bool) で
並列にメタデータを埋めます。ID だけでよければ hydrate を false に。
public Task<List<Space>> SearchAsync(string query, string filter = "Live", bool hydrate = true)
Parameters
Returns
SetSpaceSettingsAsync(string, int)
発言できる相手を変更します: 0=リクエスト/承認、1=フォロー中、2=全員。
public Task<JsonObject> SetSpaceSettingsAsync(string spaceId, int conversationControls)
Parameters
Returns
SpeakAsync(Space, object, IPeerConnectionFactory, IReadOnlyList<IceServer>?, string?, bool, bool)
スピーカーとして参加し、WebRTC の publish セッションを開きます(IPeerConnectionFactory が必要)。
public Task<SpaceVoiceSession> SpeakAsync(Space space, object audioTrack, IPeerConnectionFactory peerConnectionFactory, IReadOnlyList<IceServer>? iceServers = null, string? sessionUuid = null, bool joinAsAdmin = false, bool shouldAutoJoin = true)
Parameters
spaceSpaceスペース。
audioTrackobject送信する音声トラック(実装固有のオブジェクト)。
peerConnectionFactoryIPeerConnectionFactoryピア接続のファクトリ。
iceServersIReadOnlyList<IceServer>ICE サーバー。既定は直接接続(X の TURN は約 60 秒で切れるため)。
sessionUuidstring既存の chatman セッションを再利用する場合の UUID(挙手が承認された後など)。
joinAsAdminbool管理者として参加するか。
shouldAutoJoinbool自動参加するか。
Returns
StreamLiveChatAsync(Space, string?, string?, bool, CancellationToken)
Web クライアントの HTTP ストリーム(/live-chat)によるライブチャット。解析済みの JSON イベント
(userId、controlType、...)を列挙します。WebSocket は不要です。
replay を true にすると終了したスペースのチャットログ(replay=1)を cursor でページ送りしながら返します。
public IAsyncEnumerable<JsonObject> StreamLiveChatAsync(Space space, string? sessionId = null, string? cursor = null, bool replay = false, CancellationToken cancellationToken = default)
Parameters
spaceSpacesessionIdstringcursorstringreplayboolcancellationTokenCancellationToken
Returns
StreamUrlAsync(Space)
ライブ / リプレイのスペースの HLS m3u8 URL。
public Task<string?> StreamUrlAsync(Space space)
Parameters
spaceSpace
Returns
SubscribeScheduledAsync(string)
public Task SubscribeScheduledAsync(string spaceId)
Parameters
spaceIdstring
Returns
TopicsAsync()
スペースのトピック一覧を取得します。
public Task<List<JsonObject>> TopicsAsync()
Returns
UnmuteSpaceAsync(string)
スペース全体のミュートを解除します(ホストのみ)。
public Task<JsonObject> UnmuteSpaceAsync(string spaceId)
Parameters
spaceIdstring
Returns
UnmuteSpeakerAsync(string, string)
public Task<JsonObject> UnmuteSpeakerAsync(string spaceId, string sessionUuid)
Parameters
Returns
UnsubscribeScheduledAsync(string)
public Task UnsubscribeScheduledAsync(string spaceId)
Parameters
spaceIdstring
Returns
WaitForSpeakerAsync(string, string, double, double)
call/status をポーリングし、セッションがスピーカーになる(ホストが承認する)まで待ちます。 タイムアウト時は null。
public Task<JsonObject?> WaitForSpeakerAsync(string spaceId, string sessionUuid, double timeoutSeconds = 120, double intervalSeconds = 3)