Table of Contents

Class FluxerGatewayClient

Namespace
Fluxer.Net.Gateway
Assembly
Fluxer.Net.dll

WebSocket gateway client for real-time events from the Fluxer platform. Handles bidirectional communication, automatic heartbeats, and reconnection with resume capability.

public class FluxerGatewayClient : IDisposable
Inheritance
object
FluxerGatewayClient
Implements

Remarks

The GatewayClient provides an event-driven architecture for receiving real-time updates from Fluxer, including messages, user presence, guild changes, and more. It implements the Fluxer Gateway protocol with support for:

  • Automatic heartbeat mechanism to maintain connection
  • Sequence tracking for ordered event processing
  • Session-based reconnection with resume capability (no event loss)
  • Event filtering via IgnoredGatewayEvents

This client should be paired with FluxerApiClient for full Fluxer functionality.

Fields

RtcRegions

public RtcRegion[] RtcRegions

Field Value

RtcRegion[]

Properties

Channels

public ConcurrentDictionary<ulong, Channel> Channels { get; }

Property Value

ConcurrentDictionary<ulong, Channel>

CurrentMembers

public ConcurrentDictionary<ulong, SocketGuildMember> CurrentMembers { get; }

Property Value

ConcurrentDictionary<ulong, SocketGuildMember>

CurrentUser

public SocketCurrentUser? CurrentUser { get; }

Property Value

SocketCurrentUser

GuildIds

public HashSet<ulong> GuildIds { get; }

Property Value

HashSet<ulong>

Guilds

public ConcurrentDictionary<ulong, SocketGuild> Guilds { get; }

Property Value

ConcurrentDictionary<ulong, SocketGuild>

Roles

public ConcurrentDictionary<ulong, SocketRole> Roles { get; }

Property Value

ConcurrentDictionary<ulong, SocketRole>

Methods

ConnectAsync()

Establishes a WebSocket connection to the Fluxer gateway and sends the IDENTIFY packet.

public Task ConnectAsync()

Returns

Task

A task that represents the asynchronous connection operation.

Remarks

This method:

  1. Creates a WebSocket connection to the gateway URL specified in configuration
  2. Sets up message and reconnection handlers
  3. Sends an IDENTIFY packet with authentication token and presence
  4. Waits for HELLO event to begin heartbeat mechanism

The connection will automatically reconnect on disconnect and attempt to resume the session.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

DownloadMembersAsync(SocketGuild)

public Task<bool> DownloadMembersAsync(SocketGuild guild)

Parameters

guild SocketGuild

Returns

Task<bool>

~FluxerGatewayClient()

protected ~FluxerGatewayClient()

GetChannel(ulong)

public Channel? GetChannel(ulong channelId)

Parameters

channelId ulong

Returns

Channel

GetCurrentMember(ulong)

public SocketGuildMember? GetCurrentMember(ulong guildId)

Parameters

guildId ulong

Returns

SocketGuildMember

GetGuild(ulong)

public SocketGuild? GetGuild(ulong guildId)

Parameters

guildId ulong

Returns

SocketGuild

GetOwnerIdAsync()

public Task<ulong?> GetOwnerIdAsync()

Returns

Task<ulong?>

GetRole(ulong)

public SocketRole? GetRole(ulong roleId)

Parameters

roleId ulong

Returns

SocketRole

SendGatewayPacket<T>(T)

Sends a gateway packet to the Fluxer WebSocket server.

public void SendGatewayPacket<T>(T Data) where T : class

Parameters

Data T

The packet data to serialize and send.

Type Parameters

T

The type of the gateway packet data.

Remarks

This method automatically schedules reconnection if sending fails. Packets may be dropped during reconnection attempts. For critical operations, use the REST API via FluxerApiClient.

SetStatus(Status, UserCustomStatusJson?)

Updates the current user's presence status on the gateway.

public void SetStatus(Status status, UserCustomStatusJson? custom)

Parameters

status Status

The new status to set (Online, Idle, DoNotDisturb, Invisible).

custom UserCustomStatusJson

Remarks

This sends a PRESENCE_UPDATE packet to the gateway. Other users will see the status change in real-time through PRESENCE_UPDATE events.

UpdateVoiceState(ulong?, ulong?, bool, bool)

Updates the current user's voice state (join/leave voice channels, mute, deafen).

public void UpdateVoiceState(ulong? guildId, ulong? channelId, bool selfMute, bool selfDeaf)

Parameters

guildId ulong?

The guild ID containing the voice channel.

channelId ulong?

The voice channel ID to join, or null to disconnect.

selfMute bool

Whether the user should be self-muted.

selfDeaf bool

Whether the user should be self-deafened.

Remarks

This sends a VOICE_STATE_UPDATE packet to the gateway. The server will respond with VOICE_STATE_UPDATE and VOICE_SERVER_UPDATE events containing connection information.

Events

AuthSessionChanged

Occurs when an auth session changes.

public event FluxerGatewayClient.AuthSessionChangedEvent AuthSessionChanged

Event Type

FluxerGatewayClient.AuthSessionChangedEvent

CallCreated

Occurs when a call is created.

public event FluxerGatewayClient.CallCreatedEvent CallCreated

Event Type

FluxerGatewayClient.CallCreatedEvent

CallDeleted

Occurs when a call is deleted.

public event FluxerGatewayClient.CallDeletedEvent CallDeleted

Event Type

FluxerGatewayClient.CallDeletedEvent

CallUpdated

Occurs when a call is updated.

public event FluxerGatewayClient.CallUpdatedEvent CallUpdated

Event Type

FluxerGatewayClient.CallUpdatedEvent

ChannelCreated

Occurs when a channel is created in a guild.

public event FluxerGatewayClient.ChannelCreatedEvent ChannelCreated

Event Type

FluxerGatewayClient.ChannelCreatedEvent

ChannelDeleted

Occurs when a channel is deleted.

public event FluxerGatewayClient.ChannelDeletedEvent ChannelDeleted

Event Type

FluxerGatewayClient.ChannelDeletedEvent

ChannelMemberCounts

public event FluxerGatewayClient.ChannelMemberCountsEvent ChannelMemberCounts

Event Type

FluxerGatewayClient.ChannelMemberCountsEvent

ChannelPinsAck

Occurs when channel pins are acknowledged.

public event FluxerGatewayClient.ChannelPinsAckEvent ChannelPinsAck

Event Type

FluxerGatewayClient.ChannelPinsAckEvent

ChannelPinsUpdated

Occurs when a message is pinned or unpinned in a channel.

public event FluxerGatewayClient.ChannelPinsUpdatedEvent ChannelPinsUpdated

Event Type

FluxerGatewayClient.ChannelPinsUpdatedEvent

ChannelUpdated

Occurs when a channel is updated.

public event FluxerGatewayClient.ChannelUpdatedEvent ChannelUpdated

Event Type

FluxerGatewayClient.ChannelUpdatedEvent

Connected

Occurs when the gateway is connected.

public event FluxerGatewayClient.ConnectedEvent Connected

Event Type

FluxerGatewayClient.ConnectedEvent

ConnectionsUpdated

Occurs on user connection updated.

public event FluxerGatewayClient.UserConnectionsUpdatedEvent ConnectionsUpdated

Event Type

FluxerGatewayClient.UserConnectionsUpdatedEvent

CurrentUserUpdated

Occurs when the current user's account is updated.

public event FluxerGatewayClient.CurrentUserUpdatedEvent CurrentUserUpdated

Event Type

FluxerGatewayClient.CurrentUserUpdatedEvent

Disconnected

Occurs when the gateway is disconnected.

public event FluxerGatewayClient.DisconnectedEvent Disconnected

Event Type

FluxerGatewayClient.DisconnectedEvent

EmojiCreated

public event FluxerGatewayClient.GuildEmojiCreatedEvent EmojiCreated

Event Type

FluxerGatewayClient.GuildEmojiCreatedEvent

EmojiDeleted

public event FluxerGatewayClient.GuildEmojiDeletedEvent EmojiDeleted

Event Type

FluxerGatewayClient.GuildEmojiDeletedEvent

EmojiUpdated

Occurs when the list of emojis in a guild is updated (added, removed, or modified).

public event FluxerGatewayClient.GuildEmojiUpdatedEvent EmojiUpdated

Event Type

FluxerGatewayClient.GuildEmojiUpdatedEvent

FavoriteMediaCreated

Occurs when a favorite meme is created.

public event FluxerGatewayClient.FavoriteMediaCreatedEvent FavoriteMediaCreated

Event Type

FluxerGatewayClient.FavoriteMediaCreatedEvent

FavoriteMediaDeleted

Occurs when a favorite meme is deleted.

public event FluxerGatewayClient.FavoriteMediaDeletedEvent FavoriteMediaDeleted

Event Type

FluxerGatewayClient.FavoriteMediaDeletedEvent

FavoriteMediaUpdated

Occurs when a favorite meme is updated.

public event FluxerGatewayClient.FavoriteMediaUpdatedEvent FavoriteMediaUpdated

Event Type

FluxerGatewayClient.FavoriteMediaUpdatedEvent

GroupUserAdded

Occurs when a recipient is added to a group DM or channel.

public event FluxerGatewayClient.GroupUserAddedEvent GroupUserAdded

Event Type

FluxerGatewayClient.GroupUserAddedEvent

GroupUserRemoved

Occurs when a recipient is removed from a group DM or channel.

public event FluxerGatewayClient.GroupUserRemovedEvent GroupUserRemoved

Event Type

FluxerGatewayClient.GroupUserRemovedEvent

GuildAvailable

Occurs when the guild becomes available again.

public event FluxerGatewayClient.GuildAvailableEvent GuildAvailable

Event Type

FluxerGatewayClient.GuildAvailableEvent

GuildJoined

Occurs when the bot joins a guild.

public event FluxerGatewayClient.GuildJoinedEvent GuildJoined

Event Type

FluxerGatewayClient.GuildJoinedEvent

GuildLeft

Occurs when the bot is removed from a guild or when a guild becomes unavailable. Check the Unavailable property to distinguish between guild outages (true) and the user being removed (false/null).

public event FluxerGatewayClient.GuildLeftEvent GuildLeft

Event Type

FluxerGatewayClient.GuildLeftEvent

GuildMemberCounts

public event FluxerGatewayClient.GuildMemberCountsEvent GuildMemberCounts

Event Type

FluxerGatewayClient.GuildMemberCountsEvent

GuildUnavailable

Occurs when the guild becomes unavailable.

public event FluxerGatewayClient.GuildUnavailableEvent GuildUnavailable

Event Type

FluxerGatewayClient.GuildUnavailableEvent

GuildUpdated

Occurs when a guild is updated (name, icon, settings, etc.).

public event FluxerGatewayClient.GuildUpdatedEvent GuildUpdated

Event Type

FluxerGatewayClient.GuildUpdatedEvent

HeartbeatAck

Occurs when the gateway acknowledges a heartbeat packet.

public event FluxerGatewayClient.HeartbeatAckEvent HeartbeatAck

Event Type

FluxerGatewayClient.HeartbeatAckEvent

InviteCreated

Occurs when a new invite is created for a guild or group DM.

public event FluxerGatewayClient.InviteCreatedEvent InviteCreated

Event Type

FluxerGatewayClient.InviteCreatedEvent

InviteDeleted

Occurs when an invite is deleted or expires.

public event FluxerGatewayClient.InviteDeletedEvent InviteDeleted

Event Type

FluxerGatewayClient.InviteDeletedEvent

MemberJoined

Occurs when a new member joins a guild.

public event FluxerGatewayClient.GuildMemberAddedEvent MemberJoined

Event Type

FluxerGatewayClient.GuildMemberAddedEvent

MemberLeft

Occurs when a member leaves a guild or is kicked/banned.

public event FluxerGatewayClient.GuildMemberRemovedEvent MemberLeft

Event Type

FluxerGatewayClient.GuildMemberRemovedEvent

MemberUpdated

Occurs when a guild member is updated (roles, nickname, avatar, etc.).

public event FluxerGatewayClient.GuildMemberUpdatedEvent MemberUpdated

Event Type

FluxerGatewayClient.GuildMemberUpdatedEvent

MessageAck

Occurs when a message is acknowledged as read by the current user.

public event FluxerGatewayClient.MessageAckEvent MessageAck

Event Type

FluxerGatewayClient.MessageAckEvent

MessageCreated

Occurs when a new message is created in any channel the user has access to.

public event FluxerGatewayClient.MessageCreatedEvent MessageCreated

Event Type

FluxerGatewayClient.MessageCreatedEvent

MessageDeleted

Occurs when a message is deleted.

public event FluxerGatewayClient.MessageDeletedEvent MessageDeleted

Event Type

FluxerGatewayClient.MessageDeletedEvent

MessageReactionAdded

Occurs when a user adds a reaction to a message.

public event FluxerGatewayClient.MessageReactionAddedEvent MessageReactionAdded

Event Type

FluxerGatewayClient.MessageReactionAddedEvent

MessageReactionRemoveAll

Occurs when all reactions are removed from a message.

public event FluxerGatewayClient.MessageReactionRemoveAllEvent MessageReactionRemoveAll

Event Type

FluxerGatewayClient.MessageReactionRemoveAllEvent

MessageReactionRemoved

Occurs when a user removes a reaction from a message.

public event FluxerGatewayClient.MessageReactionRemovedEvent MessageReactionRemoved

Event Type

FluxerGatewayClient.MessageReactionRemovedEvent

MessageReactionRemovedEmoji

Occurs when all instances of a specific emoji are removed from a message.

public event FluxerGatewayClient.MessageReactionRemovedEmojiEvent MessageReactionRemovedEmoji

Event Type

FluxerGatewayClient.MessageReactionRemovedEmojiEvent

MessageUpdated

Occurs when a message is edited.

public event FluxerGatewayClient.MessageUpdatedEvent MessageUpdated

Event Type

FluxerGatewayClient.MessageUpdatedEvent

MessagesDeleted

Occurs when multiple messages are deleted in bulk (e.g., purge operation).

public event FluxerGatewayClient.MessageDeleteBulkEvent MessagesDeleted

Event Type

FluxerGatewayClient.MessageDeleteBulkEvent

PresenceUpdated

Occurs when a user's presence (online status) changes.

public event FluxerGatewayClient.PresenceUpdatedEvent PresenceUpdated

Event Type

FluxerGatewayClient.PresenceUpdatedEvent

RateLimited

Occurs on rate limited.

public event FluxerGatewayClient.RateLimitedEvent RateLimited

Event Type

FluxerGatewayClient.RateLimitedEvent

Ready

Occurs when the gateway connection is established and initial data is received. Contains session ID, current user information, and initial guilds/channels/DMs.

public event FluxerGatewayClient.ReadyEvent Ready

Event Type

FluxerGatewayClient.ReadyEvent

RecentMentionDeleted

Occurs when a recent mention is deleted.

public event FluxerGatewayClient.RecentMentionDeletedEvent RecentMentionDeleted

Event Type

FluxerGatewayClient.RecentMentionDeletedEvent

RelationshipAdded

Occurs when a relationship (friend, blocked user, etc.) is added.

public event FluxerGatewayClient.RelationshipAddedEvent RelationshipAdded

Event Type

FluxerGatewayClient.RelationshipAddedEvent

RelationshipRemoved

Occurs when a relationship is removed.

public event FluxerGatewayClient.RelationshipRemovedEvent RelationshipRemoved

Event Type

FluxerGatewayClient.RelationshipRemovedEvent

RelationshipUpdated

Occurs when a relationship is updated.

public event FluxerGatewayClient.RelationshipUpdatedEvent RelationshipUpdated

Event Type

FluxerGatewayClient.RelationshipUpdatedEvent

Resumed

Occurs when a disconnected session is successfully resumed without data loss.

public event FluxerGatewayClient.ResumedEvent Resumed

Event Type

FluxerGatewayClient.ResumedEvent

RoleCreated

Occurs when a new role is created in a guild.

public event FluxerGatewayClient.GuildRoleCreatedEvent RoleCreated

Event Type

FluxerGatewayClient.GuildRoleCreatedEvent

RoleDeleted

Occurs when a role is deleted from a guild.

public event FluxerGatewayClient.GuildRoleDeletedEvent RoleDeleted

Event Type

FluxerGatewayClient.GuildRoleDeletedEvent

RoleUpdated

Occurs when a role is updated (name, color, permissions, etc.).

public event FluxerGatewayClient.GuildRoleUpdatedEvent RoleUpdated

Event Type

FluxerGatewayClient.GuildRoleUpdatedEvent

SavedMessageCreated

Occurs when a message is saved.

public event FluxerGatewayClient.SavedMessageCreatedEvent SavedMessageCreated

Event Type

FluxerGatewayClient.SavedMessageCreatedEvent

SavedMessageDeleted

Occurs when a saved message is deleted.

public event FluxerGatewayClient.SavedMessageDeletedEvent SavedMessageDeleted

Event Type

FluxerGatewayClient.SavedMessageDeletedEvent

SessionsReplaced

Occurs when auth sessions are replaced.

public event FluxerGatewayClient.SessionsReplacedEvent SessionsReplaced

Event Type

FluxerGatewayClient.SessionsReplacedEvent

StickerCreated

public event FluxerGatewayClient.GuildStickerCreatedEvent StickerCreated

Event Type

FluxerGatewayClient.GuildStickerCreatedEvent

StickerDeleted

public event FluxerGatewayClient.GuildStickerDeletedEvent StickerDeleted

Event Type

FluxerGatewayClient.GuildStickerDeletedEvent

StickerUpdated

Occurs when the list of stickers in a guild is updated (added, removed, or modified).

public event FluxerGatewayClient.GuildStickerUpdatedEvent StickerUpdated

Event Type

FluxerGatewayClient.GuildStickerUpdatedEvent

TypingStarted

Occurs when a user starts typing in a channel.

public event FluxerGatewayClient.TypingStartEvent TypingStarted

Event Type

FluxerGatewayClient.TypingStartEvent

UserBanned

Occurs when a user is banned from a guild.

public event FluxerGatewayClient.GuildBanAddedEvent UserBanned

Event Type

FluxerGatewayClient.GuildBanAddedEvent

UserGuildSettingsUpdated

Occurs when user guild settings are updated.

public event FluxerGatewayClient.UserGuildSettingsUpdatedEvent UserGuildSettingsUpdated

Event Type

FluxerGatewayClient.UserGuildSettingsUpdatedEvent

UserNoteUpdated

Occurs when a user note is updated.

public event FluxerGatewayClient.UserNoteUpdatedEvent UserNoteUpdated

Event Type

FluxerGatewayClient.UserNoteUpdatedEvent

UserPinnedDMsUpdated

Occurs when pinned DMs are updated.

public event FluxerGatewayClient.UserPinnedDMsUpdatedEvent UserPinnedDMsUpdated

Event Type

FluxerGatewayClient.UserPinnedDMsUpdatedEvent

UserSettingsUpdated

Occurs when user settings are updated.

public event FluxerGatewayClient.UserSettingsUpdatedEvent UserSettingsUpdated

Event Type

FluxerGatewayClient.UserSettingsUpdatedEvent

UserUnbanned

Occurs when a user is unbanned from a guild.

public event FluxerGatewayClient.GuildBanRemovedEvent UserUnbanned

Event Type

FluxerGatewayClient.GuildBanRemovedEvent

VoiceServerUpdated

Occurs when voice server information is updated (used for establishing voice connections).

public event FluxerGatewayClient.VoiceServerUpdatedEvent VoiceServerUpdated

Event Type

FluxerGatewayClient.VoiceServerUpdatedEvent

VoiceStateUpdated

Occurs when a user joins, leaves, or updates their state in a voice channel.

public event FluxerGatewayClient.VoiceStateUpdatedEvent VoiceStateUpdated

Event Type

FluxerGatewayClient.VoiceStateUpdatedEvent

WebhooksUpdated

Occurs when webhooks are created, updated, or deleted in a channel.

public event FluxerGatewayClient.WebhooksUpdatedEvent WebhooksUpdated

Event Type

FluxerGatewayClient.WebhooksUpdatedEvent