messaging

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMessageValidator added in v1.3.4

func DefaultMessageValidator(msg *messages.GlideMessage) (error, *messages.GlideMessage)

Types

type ActionHandler added in v1.2.1

type ActionHandler struct {
	// contains filtered or unexported fields
}

ActionHandler is a handler for a specific message action.

func NewActionHandler added in v1.2.1

func NewActionHandler(action messages.Action, fn HandlerFunc) *ActionHandler

func (*ActionHandler) Handle added in v1.2.1

func (a *ActionHandler) Handle(h *MessageInterfaceImpl, cliInfo *gate.Info, message *messages.GlideMessage) bool

type ActionWithReplyHandler added in v1.2.1

type ActionWithReplyHandler struct {
	// contains filtered or unexported fields
}

ActionWithReplyHandler is a handler for a specific message action, this handler will return a reply message.

func NewActionWithReplyHandler added in v1.2.1

func NewActionWithReplyHandler(action messages.Action, fn ReplyHandlerFunc) *ActionWithReplyHandler

func (*ActionWithReplyHandler) Handle added in v1.2.1

type HandlerFunc

type HandlerFunc func(cliInfo *gate.Info, message *messages.GlideMessage) error

HandlerFunc is used to handle message with specified action in ActionHandler

type Interface

type Interface interface {

	// Handle handles message from gate, the entry point for the messaging.
	Handle(clientInfo *gate.Info, msg *messages.GlideMessage) error

	AddHandler(i MessageHandler)
}

Interface for messaging.

type MessageHandler added in v1.2.1

type MessageHandler interface {
	// Handle handles the message, returns true if the message is handled,
	// otherwise the message is delegated to next handler.
	Handle(h *MessageInterfaceImpl, cliInfo *gate.Info, message *messages.GlideMessage) bool
}

MessageHandler is the interface for message handler

type MessageInterfaceImpl added in v1.2.1

type MessageInterfaceImpl struct {
	// contains filtered or unexported fields
}

MessageInterfaceImpl default implementation of the messaging interface.

func NewDefaultImpl

func NewDefaultImpl(options *Options) (*MessageInterfaceImpl, error)

func (*MessageInterfaceImpl) AddHandler added in v1.2.1

func (d *MessageInterfaceImpl) AddHandler(i MessageHandler)

func (*MessageInterfaceImpl) GetClientInterface added in v1.2.1

func (d *MessageInterfaceImpl) GetClientInterface() gate.Gateway

func (*MessageInterfaceImpl) GetGroupInterface added in v1.2.1

func (d *MessageInterfaceImpl) GetGroupInterface() subscription.Interface

func (*MessageInterfaceImpl) Handle added in v1.2.1

func (d *MessageInterfaceImpl) Handle(cInfo *gate.Info, msg *messages.GlideMessage) error

func (*MessageInterfaceImpl) OnHandleMessageError added in v1.2.1

func (d *MessageInterfaceImpl) OnHandleMessageError(cInfo *gate.Info, msg *messages.GlideMessage, err error)

func (*MessageInterfaceImpl) SetGate added in v1.2.1

func (d *MessageInterfaceImpl) SetGate(g gate.Gateway)

func (*MessageInterfaceImpl) SetNotifyErrorOnServer added in v1.3.2

func (d *MessageInterfaceImpl) SetNotifyErrorOnServer(enable bool)

func (*MessageInterfaceImpl) SetSubscription added in v1.2.1

func (d *MessageInterfaceImpl) SetSubscription(g subscription.Interface)

type MessageValidationHandler added in v1.3.4

type MessageValidationHandler struct {
	// contains filtered or unexported fields
}

MessageValidationHandler validates message before handling

func NewMessageValidationHandler added in v1.3.4

func NewMessageValidationHandler(validators ...MessageValidator) *MessageValidationHandler

func (*MessageValidationHandler) Handle added in v1.3.4

type MessageValidator added in v1.3.4

type MessageValidator = func(msg *messages.GlideMessage) (error, *messages.GlideMessage)

MessageValidator is used to validate message. if error is not nil, this message will be handled by MessageValidationHandler the second return value is the reply message, if not nil, the message will be sent to the client, if nil, the MessageValidationHandler will return the error message

type Messaging

type Messaging interface {
	Interface

	SetSubscription(g subscription.Interface)

	SetGate(g gate.Gateway)
}

type Options added in v1.3.7

type Options struct {
	NotifyServerError     bool
	MaxMessageConcurrency int
}

type ReplyHandlerFunc added in v1.2.1

type ReplyHandlerFunc func(cliInfo *gate.Info, message *messages.GlideMessage) (*messages.GlideMessage, error)

type Server

type Server interface {
	Messaging

	Run() error
}

Server is the messaging server.

Jump to

Keyboard shortcuts

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