send. allow "nil" arguments to send, emit, broadcast

This commit is contained in:
Gennadii Kovalev 2016-05-27 14:51:37 +02:00
parent 79023de6ce
commit ec90f20e1f
1 changed files with 7 additions and 5 deletions

View File

@ -16,12 +16,14 @@ var (
Send message packet to socket Send message packet to socket
*/ */
func send(msg *protocol.Message, c *Channel, args interface{}) error { func send(msg *protocol.Message, c *Channel, args interface{}) error {
if args != nil {
json, err := json.Marshal(&args) json, err := json.Marshal(&args)
if err != nil { if err != nil {
return err return err
} }
msg.Args = string(json) msg.Args = string(json)
}
command, err := protocol.Encode(msg) command, err := protocol.Encode(msg)
if err != nil { if err != nil {