Skip to content

Commit

Permalink
some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
cyteon committed Jul 17, 2024
1 parent dc74a9a commit ed62dba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
30 changes: 0 additions & 30 deletions src/discord_gleam/discord/snowflake.gleam

This file was deleted.

12 changes: 7 additions & 5 deletions src/discord_gleam/ws/event_loop.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type Msg {
}

pub type State {
State(has_received_hello: Bool, sequence: Int)
State(has_received_hello: Bool, s: Int)
}

pub fn main(bot: bot.Bot, event_handlers: List(event_handler.EventHandler)) {
Expand All @@ -42,7 +42,7 @@ pub fn main(bot: bot.Bot, event_handlers: List(event_handler.EventHandler)) {

logging.log(logging.Debug, "Creating builder")

let initial_state = State(has_received_hello: False, sequence: 0)
let initial_state = State(has_received_hello: False, s: 0)
let builder =
stratus.websocket(
request: req,
Expand All @@ -59,7 +59,7 @@ pub fn main(bot: bot.Bot, event_handlers: List(event_handler.EventHandler)) {
let identify = identify.create_packet(bot.token)
let _ = stratus.send_text_message(conn, identify)

let new_state = State(has_received_hello: True, sequence: 0)
let new_state = State(has_received_hello: True, s: 0)

let heartbeat = hello.string_to_data(msg)

Expand All @@ -68,7 +68,9 @@ pub fn main(bot: bot.Bot, event_handlers: List(event_handler.EventHandler)) {
repeatedly.call(heartbeat, Nil, fn(_state, _count_) {
let packet =
"{\"op\": 1, \"d\": null, \"s\": "
<> int.to_string(state.sequence)
<> int.to_string(state.s)
// TODO: This is wrong, its always 0???
// Might be an issue with state cause this is in a process
<> "}"

logging.log(
Expand All @@ -88,7 +90,7 @@ pub fn main(bot: bot.Bot, event_handlers: List(event_handler.EventHandler)) {
let generic_packet = generic.string_to_data(msg)

let new_state =
State(has_received_hello: True, sequence: generic_packet.s)
State(has_received_hello: True, s: generic_packet.s)

event_handler.handle_event(bot, msg, event_handlers)

Expand Down

0 comments on commit ed62dba

Please sign in to comment.