You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
293 B

package ws
import (
"encoding/json"
"errors"
"gopkg.in/olahol/melody.v1"
)
func WriteJsonWithSession(s *melody.Session, body interface{}) error {
if s == nil {
return errors.New("session is nil")
}
bs, err := json.Marshal(body)
if err != nil {
return err
}
return s.Write(bs)
}