chat

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0, BSD-2-Clause Imports: 15 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PayloadName defines the name of the chat payload.
	PayloadName = "chat"
)
View Source
const (
	// PluginName contains the human readable name of the plugin.
	PluginName = "Chat"
)

Variables

View Source
var Events = pluginEvents{

	MessageReceived: events.NewEvent(chatEventCaller),
}

Events defines the events of the plugin.

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

func App

func App() *node.Plugin

App gets the plugin instance.

func SendChatMessage

func SendChatMessage(c echo.Context) error

SendChatMessage sends a chat message.

Types

type ChatEvent

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

ChatEvent defines the information passed when a chat event fires.

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.

type Request

type Request struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Message string `json:"message"`
}

Request defines the chat message to send

type Response

type Response struct {
	MessageID string `json:"messageID,omitempty"`
	Error     string `json:"error,omitempty"`
}

Response contains the ID of the message sent.

Jump to

Keyboard shortcuts

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