chat

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PayloadName defines the name of the chat payload.
	PayloadName = "chat"
)

Variables

View Source
var Type = payload.NewType(payloadType, PayloadName)

Type represents the identifier which addresses the chat payload type.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Events
}

Chat manages chats happening over the Tangle.

func NewChat

func NewChat() *Chat

NewChat creates a new Chat.

type Event

type Event struct {
	From      string
	To        string
	Message   string
	Timestamp time.Time
	MessageID string
}

Event defines the information passed when a chat event fires.

type Events

type Events struct {
	// Fired when a chat message is received.
	MessageReceived *events.Event
}

Events define events occurring within a Chat.

type Payload

type Payload struct {
	From    string `serix:"0,lengthPrefixType=uint32"`
	To      string `serix:"1,lengthPrefixType=uint32"`
	Message string `serix:"2,lengthPrefixType=uint32"`
	// contains filtered or unexported fields
}

Payload represents the chat payload type.

func FromBytes

func FromBytes(bytes []byte) (payloadDecoded *Payload, consumedBytes int, err error)

FromBytes parses the marshaled version of a Payload into a Go object. It either returns a new Payload or fills an optionally provided Payload with the parsed information.

func NewPayload

func NewPayload(from, to, message string) *Payload

NewPayload creates a new chat payload.

func (*Payload) Bytes

func (p *Payload) Bytes() []byte

Bytes returns a marshaled version of this Payload.

func (*Payload) String

func (p *Payload) String() string

String returns a human-friendly representation of the Payload.

func (*Payload) Type

func (p *Payload) Type() payload.Type

Type returns the type of the Payload.

Jump to

Keyboard shortcuts

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