socketeer

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionIdDoestExist = errors.New("ConnectionId Does not Exist")

Functions

This section is empty.

Types

type Action

type Action struct {
	ActionName string `json:"action"`
}

type ActionHandler

type ActionHandler func(message []byte, allSendChannels map[string]chan []byte)

type Config

type Config struct {
	PongWait           int
	PingPeriod         int
	WriteWait          int
	MaxMessageSize     int64
	MaxReadBufferSize  int
	MaxWriteBufferSize int
}

type Dispatcher

type Dispatcher interface {
	Run(commander *Manager)
}

type IdFactory

type IdFactory func() string

type Identifier

type Identifier interface {
	GetUniqueId() string
}

type Manager

type Manager struct {
	sync.Mutex

	IdGen  IdFactory
	Config *Config
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) AddDispatcher

func (s *Manager) AddDispatcher(dispatcher Dispatcher)

for dispatcher handling

func (*Manager) AddIdFactory

func (s *Manager) AddIdFactory(idGen IdFactory)

func (*Manager) AddMessageHandler

func (s *Manager) AddMessageHandler(handler MessageHandler)

func (*Manager) Broadcast

func (s *Manager) Broadcast(message []byte)

func (*Manager) Init

func (s *Manager) Init()

func (*Manager) Manage

func (s *Manager) Manage(response http.ResponseWriter, request *http.Request) (string, error)

func (*Manager) OnConnect

func (s *Manager) OnConnect(onConnectHandler OnConnectFunc)

func (*Manager) OnDisconnect

func (s *Manager) OnDisconnect(onDisconnectHandler OnDisconnectFunc)

func (*Manager) Remove

func (s *Manager) Remove(connectionId string)

func (*Manager) SendToId

func (s *Manager) SendToId(connectionId string, message []byte) error

type MessageContext

type MessageContext struct {
	From string
	Body []byte
}

type MessageHandler

type MessageHandler interface {
	OnMessage(manager *Manager, ctx *MessageContext)
}

type OnConnectFunc

type OnConnectFunc func(*Manager, *http.Request, string)

type OnConnectHandler

type OnConnectHandler interface {
	OnConnect(manager *Manager, request *http.Request, connectionId string)
}

type OnDisconnectFunc

type OnDisconnectFunc func(*Manager, string)

type OnDisconnectHandler

type OnDisconnectHandler interface {
	OnDisconnect(manager *Manager, connectionId string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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