From bb857ced6b958100568034daba99c186278d8259 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 19 Sep 2018 11:59:27 +0200 Subject: [PATCH] Add method to remove message handler --- handler.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/handler.go b/handler.go index d8668dd..0a13421 100644 --- a/handler.go +++ b/handler.go @@ -2,9 +2,10 @@ package gosocketio import ( "encoding/json" - "forge.cadoles.com/Pyxis/golang-socketio/protocol" - "sync" "reflect" + "sync" + + "forge.cadoles.com/Pyxis/golang-socketio/protocol" ) const ( @@ -52,6 +53,15 @@ func (m *methods) On(method string, f interface{}) error { return nil } +/** +Remove message processing function +*/ +func (m *methods) Off(method string) { + m.messageHandlersLock.Lock() + defer m.messageHandlersLock.Unlock() + delete(m.messageHandlers, method) +} + /** Find message processing function associated with given method */