From 54348e9cc5d0036fb26303ecd5f3fd3af66e30c6 Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Tue, 31 May 2016 13:50:53 +0300 Subject: [PATCH] Fix https://github.com/kataras/iris/issues/161 --- websocket/connection.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/websocket/connection.go b/websocket/connection.go index 179c7dda..418016d8 100644 --- a/websocket/connection.go +++ b/websocket/connection.go @@ -5,6 +5,8 @@ import ( "bytes" + "strconv" + "github.com/iris-contrib/websocket" "github.com/kataras/iris/config" "github.com/kataras/iris/utils" @@ -156,7 +158,14 @@ func (c *connection) messageReceived(data []byte) { if fn, ok := listeners[i].(func()); ok { // its a simple func(){} callback fn() } else if fnString, ok := listeners[i].(func(string)); ok { - fnString(customMessage.(string)) + + if msgString, is := customMessage.(string); is { + fnString(msgString) + } else if msgInt, is := customMessage.(int); is { + // here if server side waiting for string but client side sent an int, just convert this int to a string + fnString(strconv.Itoa(msgInt)) + } + } else if fnInt, ok := listeners[i].(func(int)); ok { fnInt(customMessage.(int)) } else if fnBool, ok := listeners[i].(func(bool)); ok {