connection

package
v0.0.0-...-682d07f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConnection

func CreateConnection(connInfo Info) (conn net.Conn, err error)

CreateConnection returns a newly created connection with connInfo or an error

func Listen

func Listen(conn net.Conn, tok token.Token, done chan<- message.Message, ec chan<- error)

Types

type Channel

type Channel struct {
	LocalChan chan Message

	RemoteChan chan Message
	// contains filtered or unexported fields
}

func (*Channel) Close

func (c *Channel) Close() error

func (*Channel) LocalAddr

func (c *Channel) LocalAddr() net.Addr

func (*Channel) Read

func (c *Channel) Read(b []byte) (n int, err error)

func (*Channel) RemoteAddr

func (c *Channel) RemoteAddr() net.Addr

func (*Channel) SetDeadline

func (c *Channel) SetDeadline(t time.Time) error

func (*Channel) SetLocalAddr

func (c *Channel) SetLocalAddr(addr ChannelAddr)

func (*Channel) SetReadDeadline

func (c *Channel) SetReadDeadline(t time.Time) error

func (*Channel) SetRemoteAddr

func (c *Channel) SetRemoteAddr(addr ChannelAddr)

func (*Channel) SetWriteDeadline

func (c *Channel) SetWriteDeadline(t time.Time) error

func (*Channel) Write

func (c *Channel) Write(b []byte) (n int, err error)

type ChannelAddr

type ChannelAddr struct {
	ID string
}

func (ChannelAddr) Network

func (c ChannelAddr) Network() string

Network returns channel

func (ChannelAddr) String

func (c ChannelAddr) String() string

String returns the channel's id

type Info

type Info struct {
	//Type determines the network address type
	Type Type

	TCPAddr  *net.TCPAddr
	ChanAddr ChannelAddr
}

Info contains address information about one actor of a connection of the declared type

func (Info) Equal

func (c Info) Equal(conn Info) bool

Equal returns true if both Connection Information have the same existing type and the values corresponding to this type are identical.

func (Info) Hash

func (c Info) Hash() string

Hash returns a string containing all information uniquely identifying a Info.

func (Info) Network

func (c Info) Network() string

Network returns the address's network name

func (Info) NetworkAndAddr

func (c Info) NetworkAndAddr() string

NetworkAndAddr returns the network name and addr of the connection separated by space

func (Info) String

func (c Info) String() string

String returns the string representation of the connection information according to its type

type Message

type Message struct {
	Sender *Channel
	Msg    []byte
}

type Type

type Type int

Type enumerates connection types

const (
	Chan Type = iota
	TCP
)

run 'go generate' in this directory if a new networkAddrType is added [source https://github.com/campoy/jsonenums]

func (Type) MarshalJSON

func (r Type) MarshalJSON() ([]byte, error)

MarshalJSON is generated so Type satisfies json.Marshaler.

func (Type) String

func (i Type) String() string

func (*Type) UnmarshalJSON

func (r *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so Type satisfies json.Unmarshaler.

Jump to

Keyboard shortcuts

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