jsoncodec

package
v0.0.0-...-be26699 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

The jsoncodec package provides a JSON codec for the rpc package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpRequest

func DumpRequest(hdr *rpc.Header, body interface{}) []byte

DumpRequest returns JSON-formatted data representing the RPC message with the given header and body, as it would be written by Codec.WriteMessage. If the body cannot be marshalled as JSON, the data will hold a JSON string describing the error.

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec implements rpc.Codec for a connection.

func New

func New(conn JSONConn) *Codec

New returns an rpc codec that uses conn to send and receive messages.

func NewNet

func NewNet(conn net.Conn) *Codec

NewNet returns an rpc codec that uses the given net connection to send and receive messages.

func NewWebsocket

func NewWebsocket(conn *websocket.Conn) *Codec

NewWebsocket returns an rpc codec that uses the given websocket connection to send and receive messages.

func (*Codec) Close

func (c *Codec) Close() error

func (*Codec) ReadBody

func (c *Codec) ReadBody(body interface{}, isRequest bool) error

func (*Codec) ReadHeader

func (c *Codec) ReadHeader(hdr *rpc.Header) error

func (*Codec) SetLogging

func (c *Codec) SetLogging(on bool)

SetLogging sets whether messages will be logged by the codec.

func (*Codec) WriteMessage

func (c *Codec) WriteMessage(hdr *rpc.Header, body interface{}) error

type JSONConn

type JSONConn interface {
	// Send sends a message.
	Send(msg interface{}) error
	// Receive receives a message into msg.
	Receive(msg interface{}) error
	Close() error
}

JSONConn sends and receives messages to an underlying connection in JSON format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL