From fd32614a632daf0e6b94ccc089c23eda4f2c47e9 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sun, 24 Jan 2016 09:49:41 -0800 Subject: [PATCH] Make compression optional, clean up some comments and unused fields. --- structs.go | 22 +++++++++------------- wsapi.go | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/structs.go b/structs.go index 762c27d..27b16e3 100644 --- a/structs.go +++ b/structs.go @@ -72,28 +72,24 @@ type Session struct { VoiceReady bool // Set to true when Voice Websocket is ready UDPReady bool // Set to true when UDP Connection is ready - // Other.. + // The websocket connection. wsConn *websocket.Conn - //TODO, add bools for like. - // are we connnected to websocket? - // have we authenticated to login? - // lets put all the general session - // tracking and infos here.. clearly - // Everything below here is used for Voice testing. - // This stuff is almost guarenteed to change a lot - // and is even a bit hackish right now. - Voice *Voice // Stores all details related to voice connections + // Stores all details related to voice connections + Voice *Voice // Managed state object, updated with events. - State *State - StateEnabled bool - StateMaxMessageCount int + State *State + StateEnabled bool // When nil, the session is not listening. listening chan interface{} + // Should the session reconnect the websocket on errors. ShouldReconnectOnError bool + + // Should the session request compressed websocket data. + Compress bool } // A VoiceRegion stores data for a specific voice region server. diff --git a/wsapi.go b/wsapi.go index 99f0426..03d987a 100644 --- a/wsapi.go +++ b/wsapi.go @@ -74,7 +74,7 @@ func (s *Session) Open() (err error) { return } - err = s.wsConn.WriteJSON(handshakeOp{2, handshakeData{3, s.Token, handshakeProperties{runtime.GOOS, "Discordgo v" + VERSION, "", "", ""}, true}}) + err = s.wsConn.WriteJSON(handshakeOp{2, handshakeData{3, s.Token, handshakeProperties{runtime.GOOS, "Discordgo v" + VERSION, "", "", ""}, s.Compress}}) if err != nil { return }