-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
voloshink
committed
Nov 19, 2017
1 parent
1e1b25c
commit 8d8167e
Showing
4 changed files
with
178 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
package dggchat | ||
|
||
type handlers struct { | ||
msgHandler func(*Message) | ||
errHandler func(string) | ||
msgHandler func(Message) | ||
errHandler func(string) | ||
joinHandler func(RoomAction) | ||
quitHandler func(RoomAction) | ||
pmHandler func(PrivateMessage) | ||
} | ||
|
||
// AddMessageHandler adds a function that will be called every time a message is received | ||
func (s *Session) AddMessageHandler(fn func(*Message)) { | ||
func (s *Session) AddMessageHandler(fn func(Message)) { | ||
s.handlers.msgHandler = fn | ||
} | ||
|
||
// AddErrorHandler adds a function that will be called every time an error message is received | ||
func (s *Session) AddErrorHandler(fn func(string)) { | ||
s.handlers.errHandler = fn | ||
} | ||
|
||
// AddJoinHandler adds a function that will be called every time a user join the chat | ||
func (s *Session) AddJoinHandler(fn func(RoomAction)) { | ||
s.handlers.joinHandler = fn | ||
} | ||
|
||
// AddQuitHandler adds a function that will be called every time a user quits the chat | ||
func (s *Session) AddQuitHandler(fn func(RoomAction)) { | ||
s.handlers.quitHandler = fn | ||
} | ||
|
||
// AddPMHandler adds a function that will be called every time a private message is received | ||
func (s *Session) AddPMHandler(fn func(PrivateMessage)) { | ||
s.handlers.pmHandler = fn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters