ASK: Request as string and writer
Opened this issue · 0 comments
rizaldirnm commented
// Broadcast sends message to all alive users.
func (c *Chat) Broadcast(method string, params Object) error {
var buf bytes.Buffer
w := wsutil.NewWriter(&buf, ws.StateServerSide, ws.OpText)
encoder := json.NewEncoder(w)
r := Request{Method: method, Params: params}
if err := encoder.Encode(r); err != nil {
return err
}
if err := w.Flush(); err != nil {
return err
}
c.out <- buf.Bytes()
return nil
}
How I can achieve when Request
is plain string so I dont need to JSON encoding. how can I write into buffer?
thank you in advance!