server

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WRITE_WAIT           = 10 * time.Second
	PONG_WAIT            = 60 * time.Second
	PING_PERIOD          = (PONG_WAIT * 9) / 10
	EVENT_IDENTITY       = "identity"
	EVENT_LOG_LINE       = "log_line"
	EVENT_SUBSCRIBER_ACK = "subscriber_ack"
)
View Source
const (
	DEFAULT_ENVIRONMENT       = "prod"
	DEFAULT_DOMAIN            = "localhost:3000"
	DEFAULT_PORT              = "3000"
	DEFAULT_LOG_LEVEL         = "warn"
	DEFAULT_READ_BUFFER_SIZE  = "0"
	DEFAULT_WRITE_BUFFER_SIZE = "0"
	DEFAULT_MAX_MESSAGE_SIZE  = "1024"
)
View Source
const (
	HTML_MAIN_INDEX = "index.html"
)

Variables

This section is empty.

Functions

func HandleIdentityMessage added in v0.1.4

func HandleIdentityMessage(payload common.IdentityMessage, client *Client, message common.Message) error

func HandleLogMessage added in v0.1.4

func HandleLogMessage(message common.LogMessage, client *Client)

func HandleMessage

func HandleMessage(client *Client, message common.Message) (common.Message, error)

func InitHttpServer

func InitHttpServer()

func Main

func Main()

func SubscriberView

func SubscriberView(context *gin.Context)

func WebsocketHandler

func WebsocketHandler(r *http.Request, w http.ResponseWriter)

Types

type Client

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

func (*Client) IsActiveBroadcaster

func (client *Client) IsActiveBroadcaster() bool

func (*Client) IsActiveSubscriber

func (client *Client) IsActiveSubscriber() bool

func (*Client) ReadIncomingMessage

func (client *Client) ReadIncomingMessage() (common.Message, error)

func (*Client) ReadPump

func (client *Client) ReadPump()

func (*Client) WritePump

func (client *Client) WritePump()

type Hub

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

Maintain the set of active clients

func NewHub

func NewHub() *Hub

func (*Hub) RemoveActiveSubscribers

func (h *Hub) RemoveActiveSubscribers(clientId string)

func (*Hub) RemoveClient

func (h *Hub) RemoveClient(clientId string, removeChannel bool)

removeChannel is a flag must be set to true to remove client send channel This flag is added to avoid removing client channel when updating the client

func (*Hub) Run

func (h *Hub) Run()

type ServerOptions

type ServerOptions struct {
	Env             string
	Domain          *common.Domain
	Port            int
	LogLevel        zapcore.Level
	ReadBufferSize  int
	WriteBufferSize int
	MaxMessageSize  int64
}

func InitOptions

func InitOptions() *ServerOptions

Jump to

Keyboard shortcuts

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