const ( // Encapsulates a user entity. MaxPendingEntitiesNum int = 100 )
const ( ProtocolVersion int = 1 )
type ID entity.ID
var ZeroID ID
func (i *ID) String() string
Info is a static Peer description for UI.
type Info struct { ShortID string ID string LocalAddr string RemoteAddr string AssociatedAddrs []string Nickname string StateName string Subscriptions []string }
Peer is responsible for communication with other nodes. Implements the Dscuss protocol.
type Peer struct { State State User *entity.User Subs subs.Subscriptions // contains filtered or unexported fields }
func New( conn *connection.Connection, owner *owner.Owner, validator Validator, goneChan chan *Peer, ) *Peer
func (p *Peer) AddAddresses(new []string)
func (p *Peer) Addresses() []string
func (p *Peer) ClearAddresses()
func (p *Peer) Close()
func (p *Peer) ID() *ID
func (p *Peer) Info() *Info
func (p *Peer) ShortID() string
func (p *Peer) String() string
State isolates peer from implementation of particular state protocol.
type State interface { ID() StateID Name() string // contains filtered or unexported methods }
StateHandshaking implements the handshaking protocol.
type StateHandshaking struct {
// contains filtered or unexported fields
}
func (s *StateHandshaking) ID() StateID
func (s *StateHandshaking) Name() string
type StateID int
const ( StateIDHandshaking StateID = iota StateIDIdle StateIDSending StateIDReceiving )
StateIdle implements the idle protocol (when peer is waiting for new entities from either side).
type StateIdle struct {
// contains filtered or unexported fields
}
func (s *StateIdle) ID() StateID
func (s *StateIdle) Name() string
StateReceiving implements the entity receiving protocol.
type StateReceiving struct {
// contains filtered or unexported fields
}
func (s *StateReceiving) ID() StateID
func (s *StateReceiving) Name() string
StateSending implements the entity sending protocol.
type StateSending struct {
// contains filtered or unexported fields
}
func (s *StateSending) ID() StateID
func (s *StateSending) Name() string
type Validator interface { ValidatePeer(*Peer) bool }