2014-04-26 09:18:56 +00:00
package ICCC
2014-10-19 17:19:11 +00:00
import (
"fmt"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
)
2014-04-26 09:18:56 +00:00
2015-06-21 18:18:23 +00:00
// Register an local command to ICCC for a specific channel.
func Registrar ( channel , command string , callback func ( data map [ string ] [ ] string ) map [ string ] [ ] string ) {
2014-04-26 09:18:56 +00:00
listenersLock . Lock ( )
defer listenersLock . Unlock ( )
2015-06-17 15:44:52 +00:00
// Write the command to the database:
2015-07-10 12:36:47 +00:00
registerLocalListener2Database ( channel , command )
2015-06-17 15:44:52 +00:00
// Register the command at the local cache:
2014-04-26 09:18:56 +00:00
listeners [ fmt . Sprintf ( ` %s::%s ` , channel , command ) ] = callback
Log . LogShort ( senderName , LM . CategorySYSTEM , LM . LevelINFO , LM . MessageNameCONFIGURATION , ` The registrar has registered a new ICCC command. ` , ` channel= ` + channel , ` command= ` + command )
}