signaling

package
v0.0.0-...-d9d33aa Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastMessage

type BroadcastMessage struct {
	Message        []byte
	IncludeClients []int
	ExcludeClients []int
}

type ClientErrorMessage

type ClientErrorMessage struct {
	ErrorCode string `json:"errorCode"`
	Message   string `json:"message"`
}

type ClientWelcomeMessage

type ClientWelcomeMessage struct {
	Id      int    `json:"id"`
	Message string `json:"message"`
}

type HttpServer

type HttpServer struct {
	HttpServerAddr string
	WsHub          *WsHub
}

func NewHttpServer

func NewHttpServer(httpServerAddr string, wsCommandFnRegistry map[string]WsCommandFn) (*HttpServer, error)

func (*HttpServer) Run

func (s *HttpServer) Run(waitGroup *sync.WaitGroup)

type ReceivedMessage

type ReceivedMessage struct {
	Sender  *WsClient
	Message []byte
}

type WsClient

type WsClient struct {
	SendMessage chan WsMessageContainer
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func (*WsClient) GetId

func (c *WsClient) GetId() int

func (*WsClient) RemoteAddrStr

func (c *WsClient) RemoteAddrStr() string

type WsCommand

type WsCommand struct {
	MessageData map[string]interface{}
	WsClient    *WsClient
	Fn          WsCommandFn
}

func NewWsCommand

func NewWsCommand(messageData map[string]interface{}, wsClient *WsClient, fn WsCommandFn) *WsCommand

func (*WsCommand) Execute

func (c *WsCommand) Execute(hub *WsHub)

type WsCommandFn

type WsCommandFn func(hub *WsHub, cmd *WsCommand)

type WsHub

type WsHub struct {
	sync.Mutex

	WsCommandFnRegistry map[string]WsCommandFn

	Broadcast chan BroadcastMessage
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

type WsMessageContainer

type WsMessageContainer struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

func NewWsMessageContainer

func NewWsMessageContainer(type_ string, data interface{}) WsMessageContainer

Jump to

Keyboard shortcuts

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