ws

package
v0.0.0-...-2984f7a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNode

func AddNode(nodeName string, read ReadMsgFunc, write WriteMsgFunc, closeCh chan struct{})

AddNode registers a node

func Done

func Done() <-chan struct{}

Done returns a channel that's closed when done

func ReceiveFromEdge

func ReceiveFromEdge() (nodeName string, msg model.Message, err error)

ReceiveFromEdge receives a message from edge

func SendToCloud

func SendToCloud(nodeName string, msg model.Message) error

SendToCloud sends the message to cloud from specified node name

func SendToEdge

func SendToEdge(nodeName string, msg *model.Message) error

SendToEdge sends the msg to nodeName

Types

type ChannelContext

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

ChannelContext is object for Context channel

func NewChannelContext

func NewChannelContext() *ChannelContext

NewChannelContext creates a ChannelContext

type ReadMsgFunc

type ReadMsgFunc func() (model.Message, error)

ReadMsgFunc defines read msg callback

type Server

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

Server defines websocket protocol server

func NewServer

func NewServer(address string) *Server

NewServer creates a websocket server

func (*Server) Close

func (srv *Server) Close() error

Close closes the server

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe listens and serves the server

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

type WriteMsgFunc

type WriteMsgFunc func(model.Message) error

WriteMsgFunc defines write msg callback

Jump to

Keyboard shortcuts

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