mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 14:47:06 +00:00
eeca435064
Update vendor Integrate rendezvous into status node Add a test with failover using rendezvous Use multiple servers in client Use discovery V5 by default and test that node can be started with rendezvous discovet Fix linter Update rendezvous client to one with instrumented stream Address feedback Fix test with updated topic limits Apply several suggestions Change log to debug for request errors because we continue execution Remove web3js after rebase Update rendezvous package
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package websocket
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
// WriteJSON is deprecated, use c.WriteJSON instead.
|
|
func WriteJSON(c *Conn, v interface{}) error {
|
|
return c.WriteJSON(v)
|
|
}
|
|
|
|
// WriteJSON writes the JSON encoding of v to the connection.
|
|
//
|
|
// See the documentation for encoding/json Marshal for details about the
|
|
// conversion of Go values to JSON.
|
|
func (c *Conn) WriteJSON(v interface{}) error {
|
|
w, err := c.NextWriter(TextMessage)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err1 := json.NewEncoder(w).Encode(v)
|
|
err2 := w.Close()
|
|
if err1 != nil {
|
|
return err1
|
|
}
|
|
return err2
|
|
}
|
|
|
|
// ReadJSON is deprecated, use c.ReadJSON instead.
|
|
func ReadJSON(c *Conn, v interface{}) error {
|
|
return c.ReadJSON(v)
|
|
}
|
|
|
|
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
|
// it in the value pointed to by v.
|
|
//
|
|
// See the documentation for the encoding/json Unmarshal function for details
|
|
// about the conversion of JSON to a Go value.
|
|
func (c *Conn) ReadJSON(v interface{}) error {
|
|
_, r, err := c.NextReader()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = json.NewDecoder(r).Decode(v)
|
|
if err == io.EOF {
|
|
// One value is expected in the message.
|
|
err = io.ErrUnexpectedEOF
|
|
}
|
|
return err
|
|
}
|