chat

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0, BSD-2-Clause Imports: 8 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, func(data []byte) (payload payload.Payload, err error) {
	var consumedBytes int
	payload, consumedBytes, err = FromBytes(data)
	if err != nil {
		return nil, err
	}
	if consumedBytes != len(data) {
		return nil, errors.New("not all payload bytes were consumed")
	}
	return
})

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
	FromLen    uint32
	To         string
	ToLen      uint32
	Message    string
	MessageLen uint32
	// contains filtered or unexported fields
}

Payload represents the chat payload type.

func FromBytes

func FromBytes(bytes []byte) (result *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 Parse

func Parse(marshalUtil *marshalutil.MarshalUtil) (result *Payload, err error)

Parse unmarshals an Payload using the given marshalUtil (for easier marshaling/unmarshaling).

func (*Payload) Bytes

func (p *Payload) Bytes() (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