Documentation ¶
Overview ¶
An implementation of the Starling protocol
Index ¶
- type Protocol
- func (proto *Protocol) BroadcastRouteRequest()
- func (proto *Protocol) DeleteContact(contact device.ContactID)
- func (proto *Protocol) JoinGroup(groupSecret device.SharedSecret) (device.ContactID, error)
- func (proto *Protocol) LinkingCreate(linkSession *contacts.LinkingSession, remoteKey []byte) (device.ContactID, error)
- func (proto *Protocol) LinkingStart() (*contacts.LinkingSession, error)
- func (proto *Protocol) LoadPersistedState()
- func (proto *Protocol) NewGroup() (device.ContactID, error)
- func (proto *Protocol) OnConnection(address device.DeviceAddress)
- func (proto *Protocol) OnDisconnection(address device.DeviceAddress)
- func (proto *Protocol) ReceivePacket(address device.DeviceAddress, packet []byte)
- func (proto *Protocol) SendMessage(session device.SessionID, message []byte) (device.MessageID, error)
- func (proto *Protocol) SyncAddMessage(contact device.ContactID, message []byte, attachedContact *device.ContactID) error
- func (proto *Protocol) SyncLoadState(contact device.ContactID, state []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
The main protocol object which keeps the state of the entire protocol stack
func NewProtocol ¶
func NewProtocol(dev device.Device, options *device.ProtocolOptions) *Protocol
NewProtocol constructs a new Protocol given device and options.
func (*Protocol) BroadcastRouteRequest ¶
func (proto *Protocol) BroadcastRouteRequest()
BroadcastRouteRequest is called to send a route request to all connected peers.
func (*Protocol) DeleteContact ¶
DeleteContact deletes the given contact such that future requests from this contact will be ignored.
func (*Protocol) LinkingCreate ¶
func (proto *Protocol) LinkingCreate(linkSession *contacts.LinkingSession, remoteKey []byte) (device.ContactID, error)
LinkingStart is used to finish a linking session and create a common contact.
func (*Protocol) LinkingStart ¶
func (proto *Protocol) LinkingStart() (*contacts.LinkingSession, error)
LinkingStart is used to initiate a linking session.
func (*Protocol) LoadPersistedState ¶
func (proto *Protocol) LoadPersistedState()
func (*Protocol) OnConnection ¶
func (proto *Protocol) OnConnection(address device.DeviceAddress)
OnConnection should be called when a new link layer connection has been established and is ready to receive messages.
func (*Protocol) OnDisconnection ¶
func (proto *Protocol) OnDisconnection(address device.DeviceAddress)
OnDisconnection should be called when a link layer connection has been broken and can no longer receive messages.
func (*Protocol) ReceivePacket ¶
func (proto *Protocol) ReceivePacket(address device.DeviceAddress, packet []byte)
ReceivePacket should be called when a new packet is received on the link layer.
func (*Protocol) SendMessage ¶
func (proto *Protocol) SendMessage(session device.SessionID, message []byte) (device.MessageID, error)
SendMessage is called to send a message on a session. The SessionID is obtained from the OnSessionEstablished function of the Device.
func (*Protocol) SyncAddMessage ¶
func (proto *Protocol) SyncAddMessage(contact device.ContactID, message []byte, attachedContact *device.ContactID) error
SyncAddMessage will add a message to a synchronized group. If attachedContact is not nil, the shared secret for the given contact will be attached to the message and shared in the group, in order for other group members to join the the attached group.
The synchronization protocol option must be enabled in order to use this method.