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

12
send.go
View File

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