gateway

package
v0.5.2-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2016 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gateway

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

Gateway implements the modules.Gateway interface.

func New

func New(addr string, persistDir string) (g *Gateway, err error)

New returns an initialized Gateway.

func (*Gateway) Address

func (g *Gateway) Address() modules.NetAddress

Address returns the NetAddress of the Gateway.

func (*Gateway) Broadcast added in v0.3.1

func (g *Gateway) Broadcast(name string, obj interface{}, peers []modules.Peer)

Broadcast calls an RPC on all of the specified peers. The calls are run in parallel. Broadcasts are restricted to "one-way" RPCs, which simply write an object and disconnect. This is why Broadcast takes an interface{} instead of an RPCFunc.

func (*Gateway) Close

func (g *Gateway) Close() error

Close saves the state of the Gateway and stops its listener process.

func (*Gateway) Connect added in v0.3.1

func (g *Gateway) Connect(addr modules.NetAddress) error

Connect establishes a persistent connection to a peer, and adds it to the Gateway's peer list.

func (*Gateway) Disconnect added in v0.3.1

func (g *Gateway) Disconnect(addr modules.NetAddress) error

Disconnect terminates a connection to a peer and removes it from the Gateway's peer list. The peer's address remains in the node list.

func (*Gateway) Peers added in v0.3.1

func (g *Gateway) Peers() []modules.Peer

Peers returns the addresses currently connected to the Gateway.

func (*Gateway) RPC

func (g *Gateway) RPC(addr modules.NetAddress, name string, fn modules.RPCFunc) error

RPC calls an RPC on the given address. RPC cannot be called on an address that the Gateway is not connected to.

func (*Gateway) RegisterConnectCall added in v0.3.1

func (g *Gateway) RegisterConnectCall(name string, fn modules.RPCFunc)

RegisterConnectCall registers a name and RPCFunc to be called on a peer upon connecting.

func (*Gateway) RegisterRPC

func (g *Gateway) RegisterRPC(name string, fn modules.RPCFunc)

RegisterRPC registers an RPCFunc as a handler for a given identifier. To call an RPC, use gateway.RPC, supplying the same identifier given to RegisterRPC. Identifiers should always use PascalCase. The first 8 characters of an identifier should be unique, as the identifier used internally is truncated to 8 bytes.

Jump to

Keyboard shortcuts

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