Documentation ¶
Index ¶
- Constants
- func CleanCallbacks()
- func ConstructCommand(message []byte, command Command) []byte
- func Fingerprint(key ed25519.PublicKey) string
- func HandleCommand(message *Message, room *Room) error
- func RegisterCommand(command Command, callback func(Command, *Message, *Room) error) error
- func RegisterRoomCommands() error
- func Sign(key ed25519.PrivateKey, data []byte) []byte
- func SyncMapsEqual(map1, map2 SyncMap) bool
- type BlobMeta
- type Command
- type ContactRequest
- type ContactResponse
- type ContentType
- type Identity
- func (i Identity) Admin() bool
- func (i Identity) Fingerprint() string
- func (i Identity) IsType(toCheck ...IdentityType) bool
- func (i Identity) Nick() string
- func (i Identity) ServiceID() string
- func (i Identity) Sign(data []byte) ([]byte, error)
- func (i Identity) String() string
- func (i Identity) URL() string
- func (i Identity) Verify(msg, sig []byte) (bool, error)
- type IdentityMeta
- type IdentityType
- type Message
- type MessageContent
- type MessageMeta
- type MessagingPeer
- type Room
- func (r *Room) AddPeers(contactIdentities ...Identity) error
- func (r *Room) Info() *RoomInfo
- func (r *Room) PeerByFingerprint(fingerprint string) (Identity, bool)
- func (r *Room) PushMessages(msgs ...Message) error
- func (r *Room) RunMessageQueueForAllPeers()
- func (r *Room) SendMessageToAllPeers(content MessageContent)
- func (r *Room) SetContext(ctx context.Context) error
- func (r *Room) StopQueues()
- type RoomInfo
- type RoomRequest
- type SyncMap
Constants ¶
View Source
const ( PubContPort = 10050 PubConvPort = 10051 )
Variables ¶
This section is empty.
Functions ¶
func CleanCallbacks ¶
func CleanCallbacks()
func ConstructCommand ¶
func Fingerprint ¶
func HandleCommand ¶
func RegisterCommand ¶
func RegisterRoomCommands ¶
func RegisterRoomCommands() error
func SyncMapsEqual ¶
Types ¶
type Command ¶
type Command string
const ( RoomCommandInvite Command = "invite" RoomCommandNameRoom Command = "name_room" RoomCommandNick Command = "nick" RoomCommandPromote Command = "promote" RoomCommandRemovePeer Command = "remove_peer" //This command is essentially a No-Op, //and is mainly used for indication in frontends RoomCommandAccept Command = "accept" CommandDelimiter = " " )
type ContactResponse ¶
type ContentType ¶
type ContentType string
const ( ContentTypeText ContentType = "mtype.text" ContentTypeCmd ContentType = "mtype.cmd" ContentTypeFile ContentType = "mtype.file" ContentTypeSticker ContentType = "mtype.sticker" )
type Identity ¶
type Identity struct { Type IdentityType `json:"type"` Priv *ed25519.PrivateKey `json:"priv,omitempty"` Pub *ed25519.PublicKey `json:"pub,omitempty"` Meta *IdentityMeta `json:"meta,omitempty"` }
func NewIdentity ¶
func NewIdentity(iType IdentityType, fingerprint string) (Identity, error)
func (Identity) Fingerprint ¶
func (Identity) IsType ¶
func (i Identity) IsType(toCheck ...IdentityType) bool
type IdentityMeta ¶
type IdentityType ¶
type IdentityType string
const ( Remote IdentityType = "RemoteIdentity" Self IdentityType = "SelfIdentity" Contact IdentityType = "ContactIdentity" )
type Message ¶
type Message struct { Meta MessageMeta `json:"meta"` Content MessageContent `json:"content"` Sig []byte `json:"sig"` }
func NewMessage ¶
func NewMessage(content MessageContent, sender Identity) Message
func (*Message) ContainsBlob ¶
func (*Message) SigIsValid ¶
func (*Message) Sign ¶
func (m *Message) Sign(key ed25519.PrivateKey)
type MessageContent ¶
type MessageContent struct { Type ContentType `json:"type"` ReplyTo *Message `json:"replyto,omitempty"` Blob *BlobMeta `json:"blob,omitempty"` Data []byte `json:"data,omitempty"` }
type MessageMeta ¶
type MessagingPeer ¶
type MessagingPeer struct { RIdentity Identity `json:"identity"` LastSyncState SyncMap `json:"lastSync"` Room *Room `json:"-"` // contains filtered or unexported fields }
func NewMessagingPeer ¶
func NewMessagingPeer(rid Identity) *MessagingPeer
func (*MessagingPeer) BumpQueue ¶
func (mp *MessagingPeer) BumpQueue()
func (*MessagingPeer) RunMessageQueue ¶
func (mp *MessagingPeer) RunMessageQueue(ctx context.Context, room *Room)
RunMessageQueue creates a cancellable context for the MessagingPeer and starts a loop that will try to send queued messages every so often.
func (*MessagingPeer) Stop ¶
func (mp *MessagingPeer) Stop()
type Room ¶
type Room struct { Self Identity `json:"self"` Peers []*MessagingPeer `json:"peers"` ID uuid.UUID `json:"uuid"` Name string `json:"name"` Messages []Message `json:"messages"` SyncState SyncMap `json:"lastMessage"` Ctx context.Context `json:"-"` // contains filtered or unexported fields }
func (*Room) AddPeers ¶
AddPeers adds a user to the Room, and if successful syncs the PeerLists. If not successful returns the error.
func (*Room) PeerByFingerprint ¶
func (*Room) PushMessages ¶
func (*Room) RunMessageQueueForAllPeers ¶
func (r *Room) RunMessageQueueForAllPeers()
func (*Room) SendMessageToAllPeers ¶
func (r *Room) SendMessageToAllPeers(content MessageContent)
func (*Room) StopQueues ¶
func (r *Room) StopQueues()
StopQueues cancels this context and with that all message queues of MessagingPeer's in this Room
type RoomRequest ¶
Click to show internal directories.
Click to hide internal directories.