Documentation ¶
Index ¶
- func ConnectToNetwork(client *xxdk.Cmix, timeout time.Duration) error
- func InitClient(password []byte, storeDir, ndfPath string) (*xxdk.Cmix, error)
- func LoadChannel(path string) (*crypto.Channel, error)
- func MaxMessagePayloadSize(maxPayloadSize int, username string) int
- func NewMessage(maxPayloadSize int, tag Tag, timestamp time.Time, username string, ...) ([]byte, error)
- func ReadRsaPrivateKey(path, channelName string) (*rsa.PrivateKey, error)
- func ReceptionCallback() (broadcast.ListenerFunc, chan ReceivedBroadcast)
- func WriteChannel(path string, s *crypto.Channel) error
- func WriteRsaPrivateKey(path, channelName string, pk *rsa.PrivateKey) error
- type BroadcastFn
- type ReceivedBroadcast
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToNetwork ¶
ConnectToNetwork connects the client to the network.
func InitClient ¶
InitClient initializes and returns a new api.Client. If a session folder already exists, then the client is loaded instead.
func LoadChannel ¶
LoadChannel loads the data from the given file path and deserializes it into a channel.
func MaxMessagePayloadSize ¶
MaxMessagePayloadSize returns the maximum size of a payload for the given max payload size and username.
func NewMessage ¶
func NewMessage(maxPayloadSize int, tag Tag, timestamp time.Time, username string, payload []byte) ([]byte, error)
NewMessage generates a new message containing the payload and the metadata.
func ReadRsaPrivateKey ¶
func ReadRsaPrivateKey(path, channelName string) (*rsa.PrivateKey, error)
ReadRsaPrivateKey reads the RSA private key PEM from the given file path. If not file path is supplied, the channel name is used instead.
func ReceptionCallback ¶
func ReceptionCallback() (broadcast.ListenerFunc, chan ReceivedBroadcast)
ReceptionCallback generates the listener callback function that the broadcast channel delivers new payloads on. Also returns a channel that receives all received broadcast messages for the UI to use to print messages.
func WriteChannel ¶
WriteChannel serialises and write the channel to the given file path. If no path is supplied, it is printed to stdout.
func WriteRsaPrivateKey ¶
func WriteRsaPrivateKey(path, channelName string, pk *rsa.PrivateKey) error
WriteRsaPrivateKey writes the RSA private key PEM to the given file path. If not file path is supplied, the channel name is used instead.
Types ¶
type BroadcastFn ¶
BroadcastFn allows the UI to pass the message and its metadata to the broadcast client.
func AsymmetricBroadcastFn ¶
func AsymmetricBroadcastFn( c broadcast.Channel, username string, pk *rsa.PrivateKey) (BroadcastFn, int)
AsymmetricBroadcastFn returns the BroadcastFn used to broadcast asymmetric broadcast messages.
func SymmetricBroadcastFn ¶
func SymmetricBroadcastFn(c broadcast.Channel, username string) (BroadcastFn, int)
SymmetricBroadcastFn returns the BroadcastFn used to broadcast symmetric broadcast messages.
type ReceivedBroadcast ¶
ReceivedBroadcast contains the broadcast message and its metadata.
type Tag ¶
type Tag uint8
Tag specifies the type of broadcast message so that it can be handled appropriately on reception.
const ( // Default indicates a normal chat messages. Default Tag = 0 // Join indicates the user has joined the channel. Join Tag = 1 // Exit indicates the user has left the channel. Exit Tag = 2 // Admin indicates that the sender has a private key and the message is sent // asymmetrically. Admin Tag = 3 )
func UnmarshalMessage ¶
UnmarshalMessage decodes the data into a payload and its metadata.