Add method to remove message handler

This commit is contained in:
wpetit 2018-09-19 11:59:27 +02:00
parent 52a9157a07
commit bb857ced6b
1 changed files with 12 additions and 2 deletions

View File

@ -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
*/