// - commands/CMDNAME - base handler for command. This what
// networker will execute on any new command. Case-insensitive.
// - internals/CMDNAME - all other internal things like database
// access.
// This map will not be changed after gonewsd initialization is
// complete.
eventsmap[string]*EventHandler
// Flag that indicates that we have completed events mapping
// initialization.
// RWMutex can be here, but we also need to write to log if we have
// completed initialization.
eventsInitializedbool
)
// Initialize initializes package.
funcInitialize(){
log.Println("Initializing event handler...")
events=make(map[string]*EventHandler)
}
// InitializeCompleted sets eventsInitialized bool to true to avoid
// all further events mapping changes.
funcInitializeCompleted(){
eventsInitialized=true
log.Println("Events initialization completed")
}
// AddEventHandler adds event handler to a list of known handlers.
funcAddEventHandler(event*EventHandler){
if!eventsInitialized{
events[event.Command]=event
}else{
log.Println("Can't add event '"+event.Command+"' to a list of known events - events mapping initialization already completed, no more changes allowed.")
}
}
// LaunchEvent launches desired event in synchronous manner.