Documentation ¶
Index ¶
- type CmdCall
- type Message
- type Session
- func (s *Session) Close() error
- func (s *Session) RegisterCmd(name, argsInfo, info string, onCmd func(CmdCall, error)) error
- func (s *Session) RegisterListener(middleware, once bool, regex string) (messageChan chan Message, middlewareResponseChan chan string, err error)
- func (s *Session) SendMessage(m Message) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct { ErrorChan chan error // contains filtered or unexported fields }
func NewSession ¶
NewSession connects to the Talk server and creates a session. The address should be in the form of "host:port".
func (*Session) RegisterCmd ¶
RegisterCmd registers a command. onCmd is called when the command is used. If onCmd returns true, the client stops listening for command usages.
func (*Session) RegisterListener ¶
func (s *Session) RegisterListener(middleware, once bool, regex string) (messageChan chan Message, middlewareResponseChan chan string, err error)
RegisterListener allows for message monitoring and intercepting/editing. Set middleware to true to intercept and edit messages. Set once to true to unregister the listener after the first message is received. Set regex to a valid regex string to only receive messages that match the regex.
messageChan will receive messages that match the regex. middlewareResponseChan is used to send back the edited message. You must send a response if middleware is true even if you don't edit the message. See example/main.go for correct usage of this function.