Task 4: fluxer-proto gateway envelope, opcodes, events #4

Closed
opened 2026-11-11 08:01:21 +00:00 by charles · 0 comments
Owner

Files:

  • Create: crates/fluxer-proto/src/gateway/{mod.rs,envelope.rs,opcodes.rs,events.rs,identify.rs,ready.rs}
  • Create: fixtures/gateway/{hello.json,ready.json,message_create.json,message_update.json,message_delete.json,typing_start.json,presence_update.json,guild_create.json,channel_update.json,unknown_event.json,invalid_session.json}
  • Test: crates/fluxer-proto/tests/gateway.rs

Interfaces:

  • Produces: Envelope { op: Opcode, d: Option<Value>, s: Option<u64>, t: Option<String> }; Opcode enum with the 18 values from fork:packages/constants/src/GatewayConstants.ts:5-24 + Unknown(u8); CloseCode 4000–4012 + Unknown(u16); IDENTIFY_FLAGS: u32 = 14; ClientProperties { os, os_version, browser: "Fluxer Native", browser_version, device: "desktop", system_locale, locale, build_version, desktop_app_version, desktop_app_channel: "stable", desktop_arch, desktop_os, e2ee_capable: false }; Identify { token, properties, presence: Option<PresenceUpdate>, flags }; Resume { token, session_id, seq }; Hello { heartbeat_interval: u64 }.
  • ReadyPayload per fork:fluxer_app/src/features/gateway/events/GatewayReady.ts:64-84: session_id, guilds: Vec<GuildReadyData>, user: UserPrivate, private_channels: Vec<Channel>, users: Vec<UserPartial>, user_settings: UserSettings, read_states: Vec<ReadState>, presences: Vec<Presence>, relationships: Vec<Value>, pinned_dms: Vec<Snowflake>; GuildReadyData { id, properties: Guild (without roles/channels), channels: Vec<Channel>, members: Vec<GuildMember>, roles: Vec<Role>, member_count, online_count, presences: Vec<Presence>, voice_states: Vec<Value>, joined_at, unavailable: bool }.
  • GatewayEvent enum: typed variants Ready, Resumed, MessageCreate(Message), MessageUpdate(MessageUpdate{id, channel_id, content: Option<String>, edited_timestamp, ..}), MessageDelete{id, channel_id, guild_id}, MessageDeleteBulk{ids, channel_id}, MessageAck{channel_id, message_id, mention_count}, TypingStart{channel_id, user_id, timestamp, guild_id}, ChannelCreate(Channel), ChannelUpdate(Channel), ChannelDelete(Channel), GuildCreate(GuildReadyData), GuildUpdate(Guild), GuildDelete{id, unavailable}, GuildMemberAdd{guild_id, member}, GuildMemberUpdate{..}, GuildMemberRemove{guild_id, user}, GuildRoleCreate/Update/Delete, PresenceUpdate(Presence), UserUpdate(UserPrivate), UserSettingsUpdate(UserSettings), ReadStateUpdate and Unknown { name: String, payload: Value }. fn GatewayEvent::from_dispatch(t: &str, d: Value) -> Result<GatewayEvent, ProtoError> — unknown t → Unknown; known t with malformed d → Err(ProtoError::Malformed{t, source}) (caller logs and continues). const DISPATCH_NAMES: [&str; 84] listing every name from fork:fluxer_app/src/features/gateway/events/EventRouter.ts:109-196 (kept for the parity test).

Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 4")

**Files:** - Create: `crates/fluxer-proto/src/gateway/{mod.rs,envelope.rs,opcodes.rs,events.rs,identify.rs,ready.rs}` - Create: `fixtures/gateway/{hello.json,ready.json,message_create.json,message_update.json,message_delete.json,typing_start.json,presence_update.json,guild_create.json,channel_update.json,unknown_event.json,invalid_session.json}` - Test: `crates/fluxer-proto/tests/gateway.rs` **Interfaces:** - Produces: `Envelope { op: Opcode, d: Option<Value>, s: Option<u64>, t: Option<String> }`; `Opcode` enum with the 18 values from `fork:packages/constants/src/GatewayConstants.ts:5-24` + `Unknown(u8)`; `CloseCode` 4000–4012 + `Unknown(u16)`; `IDENTIFY_FLAGS: u32 = 14`; `ClientProperties { os, os_version, browser: "Fluxer Native", browser_version, device: "desktop", system_locale, locale, build_version, desktop_app_version, desktop_app_channel: "stable", desktop_arch, desktop_os, e2ee_capable: false }`; `Identify { token, properties, presence: Option<PresenceUpdate>, flags }`; `Resume { token, session_id, seq }`; `Hello { heartbeat_interval: u64 }`. - `ReadyPayload` per `fork:fluxer_app/src/features/gateway/events/GatewayReady.ts:64-84`: `session_id, guilds: Vec<GuildReadyData>, user: UserPrivate, private_channels: Vec<Channel>, users: Vec<UserPartial>, user_settings: UserSettings, read_states: Vec<ReadState>, presences: Vec<Presence>, relationships: Vec<Value>, pinned_dms: Vec<Snowflake>`; `GuildReadyData { id, properties: Guild (without roles/channels), channels: Vec<Channel>, members: Vec<GuildMember>, roles: Vec<Role>, member_count, online_count, presences: Vec<Presence>, voice_states: Vec<Value>, joined_at, unavailable: bool }`. - `GatewayEvent` enum: typed variants `Ready, Resumed, MessageCreate(Message), MessageUpdate(MessageUpdate{id, channel_id, content: Option<String>, edited_timestamp, ..}), MessageDelete{id, channel_id, guild_id}, MessageDeleteBulk{ids, channel_id}, MessageAck{channel_id, message_id, mention_count}, TypingStart{channel_id, user_id, timestamp, guild_id}, ChannelCreate(Channel), ChannelUpdate(Channel), ChannelDelete(Channel), GuildCreate(GuildReadyData), GuildUpdate(Guild), GuildDelete{id, unavailable}, GuildMemberAdd{guild_id, member}, GuildMemberUpdate{..}, GuildMemberRemove{guild_id, user}, GuildRoleCreate/Update/Delete, PresenceUpdate(Presence), UserUpdate(UserPrivate), UserSettingsUpdate(UserSettings), ReadStateUpdate` and `Unknown { name: String, payload: Value }`. `fn GatewayEvent::from_dispatch(t: &str, d: Value) -> Result<GatewayEvent, ProtoError>` — unknown `t` → `Unknown`; known `t` with malformed `d` → `Err(ProtoError::Malformed{t, source})` (caller logs and continues). `const DISPATCH_NAMES: [&str; 84]` listing every name from `fork:fluxer_app/src/features/gateway/events/EventRouter.ts:109-196` (kept for the parity test). --- Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 4")
charles added this to the Foundation milestone 2026-11-11 08:01:21 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#4
No description provided.