summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/websocket_managed_conn.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-16 14:29:46 +0200
committerWim <wim@42.be>2017-07-16 14:29:46 +0200
commitaec5e3d77b6e480d04dd8773723de62416a94919 (patch)
tree57ab269e6c46e62e61db04a9ca6fbb55e736519f /vendor/github.com/nlopes/slack/websocket_managed_conn.go
parent335ddf8db543bf64522196e6928c3d10af64694c (diff)
downloadmatterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.tar.gz
matterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.tar.bz2
matterbridge-msglm-aec5e3d77b6e480d04dd8773723de62416a94919.zip
Update vendor (nlopes/slack)
Diffstat (limited to 'vendor/github.com/nlopes/slack/websocket_managed_conn.go')
-rw-r--r--vendor/github.com/nlopes/slack/websocket_managed_conn.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/vendor/github.com/nlopes/slack/websocket_managed_conn.go b/vendor/github.com/nlopes/slack/websocket_managed_conn.go
index 65bb7299..762b8f11 100644
--- a/vendor/github.com/nlopes/slack/websocket_managed_conn.go
+++ b/vendor/github.com/nlopes/slack/websocket_managed_conn.go
@@ -29,7 +29,7 @@ func (rtm *RTM) ManageConnection() {
connectionCount++
// start trying to connect
// the returned err is already passed onto the IncomingEvents channel
- info, conn, err := rtm.connect(connectionCount)
+ info, conn, err := rtm.connect(connectionCount, rtm.useRTMStart)
// if err != nil then the connection is sucessful - otherwise it is
// fatal
if err != nil {
@@ -64,7 +64,9 @@ func (rtm *RTM) ManageConnection() {
// connect attempts to connect to the slack websocket API. It handles any
// errors that occur while connecting and will return once a connection
// has been successfully opened.
-func (rtm *RTM) connect(connectionCount int) (*Info, *websocket.Conn, error) {
+// If useRTMStart is false then it uses rtm.connect to create the connection,
+// otherwise it uses rtm.start.
+func (rtm *RTM) connect(connectionCount int, useRTMStart bool) (*Info, *websocket.Conn, error) {
// used to provide exponential backoff wait time with jitter before trying
// to connect to slack again
boff := &backoff{
@@ -81,7 +83,7 @@ func (rtm *RTM) connect(connectionCount int) (*Info, *websocket.Conn, error) {
ConnectionCount: connectionCount,
}}
// attempt to start the connection
- info, conn, err := rtm.startRTMAndDial()
+ info, conn, err := rtm.startRTMAndDial(useRTMStart)
if err == nil {
return info, conn, nil
}
@@ -105,10 +107,19 @@ func (rtm *RTM) connect(connectionCount int) (*Info, *websocket.Conn, error) {
}
}
-// startRTMAndDial attemps to connect to the slack websocket. It returns the
-// full information returned by the "rtm.start" method on the slack API.
-func (rtm *RTM) startRTMAndDial() (*Info, *websocket.Conn, error) {
- info, url, err := rtm.StartRTM()
+// startRTMAndDial attempts to connect to the slack websocket. If useRTMStart is true,
+// then it returns the full information returned by the "rtm.start" method on the
+// slack API. Else it uses the "rtm.connect" method to connect
+func (rtm *RTM) startRTMAndDial(useRTMStart bool) (*Info, *websocket.Conn, error) {
+ var info *Info
+ var url string
+ var err error
+
+ if useRTMStart {
+ info, url, err = rtm.StartRTM()
+ } else {
+ info, url, err = rtm.ConnectRTM()
+ }
if err != nil {
return nil, nil, err
}