// ReadMessage reads from the websocket and unmarshals it into a birpc.Message func (c *codec) ReadMessage(msg *birpc.Message) error { c.rmu.Lock() defer c.rmu.Unlock() mt, r, err := c.ws.NextReader() // ignoring message type if mt != websocket.BinaryMessage { return ErrInvalidMsg } if err != nil { return err } c.r.Reset(r) m := &mpc.Message{} err = m.DecodeMsg(c.r) if err != nil { return err } msg.ID = m.ID msg.Func = m.Func msg.Args = m.Args msg.Result = m.Result if m.Error != nil { *msg.Error = birpc.Error{Msg: m.Error.Msg} } return nil }
func (c *codec) ReadMessage(msg *birpc.Message) error { var jm jsonMessage err := c.dec.Decode(&jm) if err != nil { return err } msg.ID = jm.ID msg.Func = jm.Func msg.Args = jm.Args msg.Result = jm.Result msg.Error = jm.Error return nil }
// ReadMessage reads from the connection and unmarshals the message // into a birpc.Message func (c *codec) ReadMessage(msg *birpc.Message) error { m := &mpc.Message{} err := m.DecodeMsg(c.r) if err != nil { return err } msg.ID = m.ID msg.Func = m.Func msg.Args = m.Args msg.Result = m.Result if m.Error != nil { *msg.Error = birpc.Error{Msg: m.Error.Msg} } return nil }
// ReadMessage listens on the redis pub-sub channel and unmarshals messages // into a birpc.Message func (c *codec) ReadMessage(msg *birpc.Message) error { c.rmu.Lock() defer c.rmu.Unlock() for { if c.sub == nil { err := c.setupSubscription() if err != nil { return err } } result, err := c.sub.Pop() if err != nil { c.sub = nil return err } if result.Value.IsNil() { continue } b := result.Value.Bytes() m := &mpc.Message{} _, err = m.UnmarshalMsg(b) if err != nil { return err } msg.ID = m.ID msg.Func = m.Func msg.Args = m.Args msg.Result = m.Result if m.Error != nil { *msg.Error = birpc.Error{Msg: m.Error.Msg} } return nil } }