models

package
v0.0.0-...-c01a966 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SignalingMessageMinByteLength = 25

Variables

View Source
var (
	DefaultPongWait, _ = time.ParseDuration("30s")
	NotAllowedToRelay  = func(destinationAddress values.Address) error {
		return errors.New(fmt.Sprintf("not allowed to relay messages to %x", destinationAddress))
	}
	IdentitiesDoNotMatch = func(clientAddress, sourceAddress values.Address) error {
		return errors.New(
			fmt.Sprintf("identities do not match, expected %x, got %x", clientAddress, sourceAddress),
		)
	}
	InvalidCookie         = errors.New("invalid cookie")
	InvalidSequenceNumber = errors.New("invalid sequence number")
)
View Source
var (
	RoomFull           = errors.New("room full")
	InitiatiorNotFound = errors.New("initiator not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ID      string
	Address values.Address

	SessionPrivateKey values.Key
	SessionPublicKey  values.Key

	PermanentPublicKey values.Key

	OutgoingCookie         values.Cookie
	OutgoingSequenceNumber values.SequenceNumber
	OutgoingOverflowNumber values.OverflowNumber

	IncomingCookie         values.Cookie
	IncomingSequenceNumber values.SequenceNumber
	IncomingOverflowNumber values.OverflowNumber
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	connection *websocket.Conn,
	room *Room,
) (*Client, error)

func (*Client) AssignToInitiator

func (c *Client) AssignToInitiator()

func (*Client) CloseConnection

func (c *Client) CloseConnection() error

func (*Client) DropConnection

func (c *Client) DropConnection(code values.CloseCode)

func (*Client) Flush

func (c *Client) Flush()

func (*Client) IncomingCombinedSequenceNumber

func (c *Client) IncomingCombinedSequenceNumber() values.CombinedSequenceNumber

func (*Client) IncomingNonceEmpty

func (c *Client) IncomingNonceEmpty() bool

func (*Client) IncrementIncomingCombinedSequenceNumber

func (c *Client) IncrementIncomingCombinedSequenceNumber() error

func (*Client) IncrementOutgoingCombinedSequenceNumber

func (c *Client) IncrementOutgoingCombinedSequenceNumber() error

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

func (*Client) IsCombinedSequenceNumberValid

func (c *Client) IsCombinedSequenceNumberValid(combinedSequenceNumber values.CombinedSequenceNumber,
) bool

func (*Client) IsCookieValid

func (c *Client) IsCookieValid(cookie values.Cookie) bool

func (*Client) IsInitiator

func (c *Client) IsInitiator() bool

func (*Client) IsP2PAllowed

func (c *Client) IsP2PAllowed(destinationAddress values.Address) bool

func (*Client) IsResponder

func (c *Client) IsResponder() bool

func (*Client) MarkAsAuthenticated

func (c *Client) MarkAsAuthenticated()

func (*Client) Nonce

func (c *Client) Nonce() values.Nonce

func (*Client) OutgoingCombinedSequenceNumber

func (c *Client) OutgoingCombinedSequenceNumber() values.CombinedSequenceNumber

func (*Client) PingTicker

func (c *Client) PingTicker(pingPeriod time.Duration, pongWait time.Duration)

func (*Client) ReadMessage

func (c *Client) ReadMessage() (messageType int, p []byte, err error)

func (*Client) SendBytes

func (c *Client) SendBytes(bytes []byte) error

func (*Client) SetAddress

func (c *Client) SetAddress(address values.Address)

func (*Client) SetIncomingNonce

func (c *Client) SetIncomingNonce(nonce values.Nonce)

func (*Client) SetPermanentPublicKey

func (c *Client) SetPermanentPublicKey(permanentPublicKey values.Key)

func (*Client) ValidateNonce

func (c *Client) ValidateNonce(nonce values.Nonce) error

type Room

type Room struct {
	InitiatorsPublicKey values.Key
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(publicKey values.Key) *Room

func (*Room) AddClient

func (r *Room) AddClient(client *Client) bool

AddClient returns false if the client was already added, otherwise adds the client and returns true

func (*Room) Client

func (r *Room) Client(address values.Address) *Client

func (*Room) CountResponders

func (r *Room) CountResponders() int

func (*Room) Initiator

func (r *Room) Initiator() *Client

func (*Room) KickCurrentInitiator

func (r *Room) KickCurrentInitiator()

func (*Room) NextFreeResponderAddress

func (r *Room) NextFreeResponderAddress() (*values.Address, error)

func (*Room) ReleaseAddress

func (r *Room) ReleaseAddress(address values.Address)

func (*Room) RemoveClient

func (r *Room) RemoveClient(client *Client) bool

RemoveClient returns true if the client with given id was found and removed, otherwise false

func (*Room) ReserveAddress

func (r *Room) ReserveAddress(address values.Address)

func (*Room) Responders

func (r *Room) Responders() []*Client

type Rooms

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

func NewRooms

func NewRooms() *Rooms

func (*Rooms) AddRoom

func (r *Rooms) AddRoom(room *Room) bool

func (*Rooms) GetOrCreateRoom

func (r *Rooms) GetOrCreateRoom(initiatorsPublicKey values.Key) *Room

func (*Rooms) GetRoom

func (r *Rooms) GetRoom(initiatorsPublicKey values.Key) *Room

func (*Rooms) RemoveRoom

func (r *Rooms) RemoveRoom(initiatorsPublicKey values.Key) bool

func (*Rooms) Size

func (r *Rooms) Size() int

type SignalingMessage

type SignalingMessage struct {
	Nonce values.Nonce
	Data  values.TypedMessage
}

func NewSignalingMessage

func NewSignalingMessage(nonce values.Nonce, data values.TypedMessage) SignalingMessage

func (SignalingMessage) Bytes

func (m SignalingMessage) Bytes() ([]byte, error)

func (SignalingMessage) DataBytes

func (m SignalingMessage) DataBytes() ([]byte, error)

func (SignalingMessage) EncryptBytes

func (m SignalingMessage) EncryptBytes(publicKey, privateKey values.Key) ([]byte, error)

func (SignalingMessage) String

func (m SignalingMessage) String() string

Jump to

Keyboard shortcuts

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