summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/websocket_managed_conn.go
diff options
context:
space:
mode:
authorPatrick Connolly <patrick.c.connolly@gmail.com>2018-12-02 02:55:35 +0800
committerWim <wim@42.be>2018-12-01 19:55:35 +0100
commite538a4d30459e9da1a021400b5de85894b4efabc (patch)
treeead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/websocket_managed_conn.go
parentf94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff)
downloadmatterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.gz
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.bz2
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.zip
Update nlopes/slack to 4.1-dev (#595)
Diffstat (limited to 'vendor/github.com/nlopes/slack/websocket_managed_conn.go')
-rw-r--r--vendor/github.com/nlopes/slack/websocket_managed_conn.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/vendor/github.com/nlopes/slack/websocket_managed_conn.go b/vendor/github.com/nlopes/slack/websocket_managed_conn.go
index e8ab65a1..62157910 100644
--- a/vendor/github.com/nlopes/slack/websocket_managed_conn.go
+++ b/vendor/github.com/nlopes/slack/websocket_managed_conn.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
+ stdurl "net/url"
"reflect"
"time"
@@ -157,6 +158,14 @@ func (rtm *RTM) startRTMAndDial(useRTMStart bool) (info *Info, _ *websocket.Conn
return nil, nil, err
}
+ // install connection parameters
+ u, err := stdurl.Parse(url)
+ if err != nil {
+ return nil, nil, err
+ }
+ u.RawQuery = rtm.connParams.Encode()
+ url = u.String()
+
rtm.Debugf("Dialing to websocket on url %s", url)
// Only use HTTPS for connections to prevent MITM attacks on the connection.
upgradeHeader := http.Header{}
@@ -274,7 +283,7 @@ func (rtm *RTM) sendWithDeadline(msg interface{}) error {
// and instead lets a future failed 'PING' detect the failed connection.
func (rtm *RTM) sendOutgoingMessage(msg OutgoingMessage) {
rtm.Debugln("Sending message:", msg)
- if len(msg.Text) > MaxMessageTextLength {
+ if len([]rune(msg.Text)) > MaxMessageTextLength {
rtm.IncomingEvents <- RTMEvent{"outgoing_error", &MessageTooLongEvent{
Message: msg,
MaxLength: MaxMessageTextLength,
@@ -405,8 +414,7 @@ func (rtm *RTM) handlePong(event json.RawMessage) {
rtm.resetDeadman()
if err := json.Unmarshal(event, &p); err != nil {
- logger.Println("RTM Error unmarshalling 'pong' event:", err)
- rtm.Debugln(" -> Erroneous 'ping' event:", string(event))
+ rtm.Client.log.Println("RTM Error unmarshalling 'pong' event:", err)
return
}
@@ -423,8 +431,8 @@ func (rtm *RTM) handlePong(event json.RawMessage) {
func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
v, exists := EventMapping[typeStr]
if !exists {
- rtm.Debugf("RTM Error, received unmapped event %q: %s\n", typeStr, string(event))
- err := fmt.Errorf("RTM Error: Received unmapped event %q: %s\n", typeStr, string(event))
+ rtm.Debugf("RTM Error - received unmapped event %q: %s\n", typeStr, string(event))
+ err := fmt.Errorf("RTM Error: Received unmapped event %q: %s", typeStr, string(event))
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
}
@@ -433,7 +441,7 @@ func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
err := json.Unmarshal(event, recvEvent)
if err != nil {
rtm.Debugf("RTM Error, could not unmarshall event %q: %s\n", typeStr, string(event))
- err := fmt.Errorf("RTM Error: Could not unmarshall event %q: %s\n", typeStr, string(event))
+ err := fmt.Errorf("RTM Error: Could not unmarshall event %q: %s", typeStr, string(event))
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
}