stompserver

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationRequestHandlerFunction

type ApplicationRequestHandlerFunction func(destination string, message []byte, connectionId string)

type ConnEvent

type ConnEvent struct {
	ConnId string
	// contains filtered or unexported fields
}

type RawConnection

type RawConnection interface {
	// Reads a single frame object
	ReadFrame() (*frame.Frame, error)
	// Sends a single frame object
	WriteFrame(frame *frame.Frame) error
	// Set deadline for reading frames
	SetReadDeadline(t time.Time)
	// Close the connection
	Close() error
}

type RawConnectionListener

type RawConnectionListener interface {
	// Blocks until a new RawConnection is established.
	Accept() (RawConnection, error)
	// Stops the connection listener.
	Close() error
}

func NewTcpConnectionListener

func NewTcpConnectionListener(addr string) (RawConnectionListener, error)

func NewWebSocketConnectionFromExistingHttpServer

func NewWebSocketConnectionFromExistingHttpServer(httpServer *http.Server, handler *mux.Router,
	endpoint string, allowedOrigins []string) (RawConnectionListener, error)

func NewWebSocketConnectionListener

func NewWebSocketConnectionListener(addr string, endpoint string, allowedOrigins []string) (RawConnectionListener, error)

type StompConfig

type StompConfig interface {
	HeartBeat() int64
	AppDestinationPrefix() []string
	IsAppRequestDestination(destination string) bool
}

func NewStompConfig

func NewStompConfig(heartBeatMs int64, appDestinationPrefix []string) StompConfig

type StompConn

type StompConn interface {
	// Return unique connection Id string
	GetId() string
	SendFrameToSubscription(f *frame.Frame, sub *subscription)
	Close()
}

func NewStompConn

func NewStompConn(rawConnection RawConnection, config StompConfig, events chan *ConnEvent) StompConn

type StompServer

type StompServer interface {
	// starts the server
	Start()
	// stops the server
	Stop()
	// sends a message to a given stomp topic destination
	SendMessage(destination string, messageBody []byte)
	// sends a message to a single connection client
	SendMessageToClient(connectionId string, destination string, messageBody []byte)
	// registers a callback for stomp subscribe events
	OnSubscribeEvent(callback SubscribeHandlerFunction)
	// registers a callback for stomp unsubscribe events
	OnUnsubscribeEvent(callback UnsubscribeHandlerFunction)
	// registers a callback for application requests
	OnApplicationRequest(callback ApplicationRequestHandlerFunction)
	// SetConnectionEventCallback is used to set up a callback when certain STOMP session events happen
	// such as ConnectionStarting, ConnectionClosed, SubscribeToTopic, UnsubscribeFromTopic and IncomingMessage.
	SetConnectionEventCallback(connEventType StompSessionEventType, cb func(connEvent *ConnEvent))
}

func NewStompServer

func NewStompServer(listener RawConnectionListener, config StompConfig) StompServer

type StompSessionEventType

type StompSessionEventType int
const (
	ConnectionStarting StompSessionEventType = iota
	ConnectionEstablished
	ConnectionClosed
	SubscribeToTopic
	UnsubscribeFromTopic
	IncomingMessage
)

type SubscribeHandlerFunction

type SubscribeHandlerFunction func(conId string, subId string, destination string, frame *frame.Frame)

type UnsubscribeHandlerFunction

type UnsubscribeHandlerFunction func(conId string, subId string, destination string)

Jump to

Keyboard shortcuts

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