import { ChannelType, ConversationType, MessageType, PartContentType, PayloadType, XboxMessage } from '.'; export type GatewayContentParts = GatewayTextContentPart | GatewayWeblinkContentPart | GatewayImageContentPart | GatewayFeedItemContentPart | GatewayWeblinkMediaContentPart | GatewayVoiceContentPart | GatewayDirectMentionContentPart; export type GatewayVoiceContentPart = { contentType: PartContentType.Voice; version: number; duration: number; voiceAttachmentId: string; }; export type GatewayWeblinkMediaContentPart = { contentType: PartContentType.WeblinkMedia; mediaType: string; mediaUri: string; text: string; version: number; unsuitableFor: string[]; }; export type GatewayFeedItemContentPart = { contentType: PartContentType.FeedItem; version: number; locator: string; }; export type GatewayImageContentPart = { contentType: PartContentType.Image; version: number; attachmentId: string; filetype: string; sizeInBytes: number; hash: string; height: number; width: number; downloadUri: string; unsuitableFor: string[]; }; export type GatewayWeblinkContentPart = { contentType: PartContentType.Weblink; version: number; text: string; unsuitableFor: string[]; }; export type GatewayTextContentPart = { contentType: PartContentType.Text; version: number; text: string; unsuitableFor: string[]; }; export type GatewayDirectMentionContentPart = { contentType: PartContentType.DirectMention; version: number; text: string; xuid: string; unsuitableFor: string[]; }; export type BaseGatewayEvent = { clientSeqNum: number; messageTime: string; senderXuid: string; senderGamertag: string; }; export type GatewayBasicTextResponse = BaseGatewayEvent & { messageType: MessageType.BasicText; channel: GatewayChannelGroupMessage; payload: { contentPayload: GatewayContentPayload; }; }; export type GatewayHorizonsResponse = BaseGatewayEvent & { messageType: MessageType.Horizons; messageId: string; channel: GatewayChannelGroupMessage; recipientFilter: string[]; horizons: { consumptionHorizon: string; directMentionHorizon: string; clearHorizon: string; }; }; export type GatewayNoOpResponse = BaseGatewayEvent & { messageType: MessageType.NoOp; messageId: string; channel: GatewayChannelSystem; flagServerOriginated: true; }; export type GatewayJoinChannelResponse = BaseGatewayEvent & { messageType: MessageType.JoinChannel; messageId: string; channel: GatewayChannelXboxMessage | GatewayChannelGroupMessage; flagLurk: boolean; connectionId: string; }; export type GatewayLeaveChannelResponse = BaseGatewayEvent & { messageType: MessageType.LeaveChannel; messageId: string; channel: GatewayChannelXboxMessage | GatewayChannelGroupMessage; flagServerOriginated: true; connectionId: string; }; export type GatewayWhoAmIResponse = BaseGatewayEvent & { messageType: MessageType.WhoAmI; messageId: string; channel: GatewayChannelSystem; connectionId: string; serverNonce: string; }; export type GatewayEventResponse = GatewayXboxMessageResponse | GatewayUserInfoResponse | GatewayBasicTextResponse | GatewayHorizonsResponse | GatewayNoOpResponse | GatewayJoinChannelResponse | GatewayLeaveChannelResponse | GatewayWhoAmIResponse; export type GatewayWhoAmIRequest = { messageType: MessageType.WhoAmI; channel: GatewayChannelSystem; clientSeqNum: number; }; export type GatewayJoinChannelRequest = { messageType: MessageType.JoinChannel; channel: GatewayChannelXboxMessage | GatewayChannelGroupMessage; flagLurk: boolean; clientSeqNum: number; }; export type GatewayEventRequest = GatewayWhoAmIRequest | GatewayJoinChannelRequest; export type GatewayChannelSystem = { type: ChannelType.System; }; export type GatewayChannelXboxMessage = { type: ChannelType.XboxMessage; id: string; }; export type GatewayChannelGroupMessage = { type: ChannelType.GroupMessage; id: string; }; export type GatewayBasePayload = { timestamp: string; lastUpdateTimestamp: string; type: PayloadType; networkId: string; conversationType: ConversationType; conversationId: string; messageId: string; clock: string; isDeleted: boolean; isServerUpdated: boolean; }; export type GatewayContentMessagePayload = GatewayBasePayload & { type: PayloadType.ContentMessage; contentPayload: { content: { parts: GatewayContentParts[]; }; }; sender: string; owner: number; notifyPayload: { shouldToast: boolean; folder: string; muted: boolean; conversationName: string; isOffensive: boolean; }; directMentionPayload?: { users: number[]; }; notificationPayload?: ConversationType.OneToOne extends ConversationType ? { shouldToast: boolean; folder: string; muted: boolean; conversationName: string; isOffensive: boolean; } : never; }; export type GatewayJoinChatChannelPayload = GatewayBasePayload & { type: PayloadType.JoinChatChannel; joinChatChannelPayload: { groupId: string; channelId: string; }; sender: string; owner: number; }; export type GatewaySetHorizonPayload = GatewayBasePayload & { type: PayloadType.SetHorizon; setHorizonPayload: { conversations: { conversationId: string; channel: { groupId: string; channelId: string; }; conversationType: ConversationType; horizon: string; horizonType: 'Read'; }[]; }; owner: number; notifyPayload: { shouldToast: false; muted: false; isOffensive: false; }; notificationPayload: { shouldToast: false; muted: false; isOffensive: false; }; }; export type GatewayXboxMessageResponse = GatewayXboxMessageContentMessage | GatewayXboxMessageSetHorizon | GatewayXboxMessageJoinChatChannel; export type GatewayXboxMessageBaseResponse = BaseGatewayEvent & { messageType: MessageType.XboxMessage; channel: GatewayChannelXboxMessage; flagServerOriginated: true; }; export type GatewayXboxMessageContentMessage = GatewayXboxMessageBaseResponse & { payload: GatewayContentMessagePayload; }; export type GatewayXboxMessageSetHorizon = GatewayXboxMessageBaseResponse & { payload: GatewaySetHorizonPayload; }; export type GatewayXboxMessageJoinChatChannel = GatewayXboxMessageBaseResponse & { payload: GatewayJoinChatChannelPayload; }; export type GatewayUserInfoPermissions = { canRead: boolean; canWrite: boolean; canModerate: boolean; canSetMotd: boolean; }; export type GatewayUserInfoResponse = BaseGatewayEvent & { messageType: MessageType.UserInfo; messageId: string; channel: GatewayChannelXboxMessage | GatewayChannelGroupMessage; flagServerOriginated: true; permissions: GatewayUserInfoPermissions; connectionId: string; }; export type GatewayContentPayload = { content: { parts: GatewayContentParts[]; }; timestamp: string; lastUpdateTimestamp: string; type: PayloadType.ContentMessage; networkId: 'Xbox'; conversationType: ConversationType; conversationId: string; sender: string; messageId: string; clock: string; isDeleted: boolean; isServerUpdated: boolean; }; export declare class WebsocketManager { client: XboxMessage; private ws; private heartbeatTimeout; private reconnectTimeout; private _sequenceId; constructor(client: XboxMessage); get sequenceId(): number; connect(): Promise; destroy(resume?: boolean): Promise; send(payload: GatewayEventRequest): void; private onOpen; private onError; private onClose; private onMessage; }