Documentation ¶
Index ¶
- Variables
- func GenerateToken(selfID, kid string, sk ed25519.PrivateKey) (string, error)
- type Encoder
- type Header
- type Message
- type Metadata
- type Notification
- type Rest
- type RestConfig
- type Websocket
- func (c *Websocket) Close() error
- func (c *Websocket) Connect() error
- func (c *Websocket) Receive() ([]byte, string, int64, []byte, error)
- func (c *Websocket) Send(recipients []string, mtype string, priority int, data []byte) error
- func (c *Websocket) SendAsync(recipients []string, mtype string, priority int, data []byte, ...)
- func (c *Websocket) SendAsyncWithID(id, recipient string, mtype string, priority int, data []byte, ...)
- type WebsocketConfig
Constants ¶
This section is empty.
Variables ¶
var ErrChannelClosed = errors.New("channel closed")
ErrChannelClosed returned when the websocket connection is shut down manually
Functions ¶
func GenerateToken ¶
func GenerateToken(selfID, kid string, sk ed25519.PrivateKey) (string, error)
GenerateToken generates a signed jwt token for use with self services
Types ¶
type Encoder ¶
type Encoder interface { MarshalAuth(device, token string, offset int64) ([]byte, error) MarshalMessage(id, sender, recipient, mtype string, priority int, ciphertext []byte) ([]byte, error) UnmarshalHeader(data []byte) (Header, error) UnmarshalNotification(data []byte) (Notification, error) UnmarshalMessage(data []byte) (Message, int64, int64, error) }
Encoder represents the interface an encoder needs to implement to work with a given protocol version
type Header ¶
type Header interface { Id() []byte Msgtype() msgprotov2.MsgType }
Header represents an event header
type Notification ¶
type Notification interface { Id() []byte Msgtype() msgprotov2.MsgType Error() []byte }
Notification represents a notification event
type Rest ¶
type Rest struct {
// contains filtered or unexported fields
}
Rest client for interacting with self's rest api
type RestConfig ¶
type RestConfig struct { SelfID string KeyID string PrivateKey ed25519.PrivateKey APIURL string Client *http.Client }
RestConfig configuration for connecting to selfs api
type Websocket ¶
type Websocket struct {
// contains filtered or unexported fields
}
Websocket websocket client for self messaging
func NewWebsocket ¶
func NewWebsocket(config WebsocketConfig) (*Websocket, error)
NewWebsocket creates a new websocket connection
func (*Websocket) Send ¶
Send send a message to given recipients. recipient is a combination of "selfID:deviceID"
type WebsocketConfig ¶
type WebsocketConfig struct { MessagingURL string SelfID string DeviceID string KeyID string Offset int64 PrivateKey ed25519.PrivateKey TCPDeadline time.Duration InboxSize int OnConnect func() OnDisconnect func(err error) OnPing func() // contains filtered or unexported fields }
WebsocketConfig configuration for connecting to a websocket