websocket

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost                = "0.0.0.0"
	DefaultPongWait            = 60 * time.Second
	DefaultPingPeriod          = (DefaultPongWait * 9) / 10
	DefaultWriteWait           = 40 * time.Second
	DefaultWsBuffer            = 1 << 23
	DefaultWsMsgNoFromCli      = 1 << 8
	DefaultUnreadMsgNoPerQuery = 1 << 13
	DefaultHandShakeTimeOut    = time.Second * 3
	DefaultDataBaseDir         = "Msg"
)
View Source
const (
	MSGPatternHead = "TempCachedMsg0"
	MSGPatternEnd  = "TempCachedMsg1"
)
View Source
const (
	CPUserOnline = "/user/online"
	CPUserCheck  = "/user/check"

	WSThreadName       = "websocket main service thread"
	PushThreadName     = "push delegate service thread"
	DispatchThreadName = "websocket message dispatcher thread"
	DatabaseThreadName = "database dirty data keeper"

	DirtyDataKeepInterval = time.Minute * 15
	DataKeptLength        = time.Hour * 24 * 7

	OnlineStreamDelim byte = '@'
)
View Source
const (
	MaxPushChanNo          = 1 << 12
	MaxPushOnline          = 1 << 10
	PushServiceStatusTimer = time.Second * 15
)
View Source
const (
	FreePackSize   = 1 << 10
	BronzePackSize = 5 * (1 << 20)
	SilverPackSize = 20 * (1 << 20)
	GoldPackSize   = 100 * (1 << 20)
)

Variables

This section is empty.

Functions

func IMDBEnd

func IMDBEnd(receiver string) []byte

func IMDBKey

func IMDBKey(receiver string, seq int64) []byte

func InitConfig

func InitConfig(c *Config)

Types

type ChatHandler

type ChatHandler func(http.ResponseWriter, *http.Request)

type Config

type Config struct {
	PingPeriod             time.Duration  `json:"ping.timeout"`
	PongWait               time.Duration  `json:"pong.timeout"`
	WriteWait              time.Duration  `json:"write.timeout"`
	HandShakeTimeout       time.Duration  `json:"handshake.timeout"`
	WsIOBufferSize         utils.ByteSize `json:"io.buffer.size"`
	MaxUnreadMsgNoPerQuery int            `json:"max.unread.size"`
	WsMsgNoFromCli         int            `json:"max.client.msg.no"`
	WsIP                   string         `json:"ws.ip"`
	WsPort                 int16          `json:"ws.port"`
	DataBaseDir            string         `json:"ws.msg.database"`
}

func DefaultConfig

func DefaultConfig(isMain bool, base string) *Config

func (*Config) String

func (c *Config) String() string

type OnlineMap

type OnlineMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*OnlineMap) AllUid

func (m *OnlineMap) AllUid() []string

func (*OnlineMap) DumpContent

func (m *OnlineMap) DumpContent() string

type PushDelegate added in v1.2.2

type PushDelegate struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*PushDelegate) Push added in v1.2.2

func (d *PushDelegate) Push(userID, msg string)

func (*PushDelegate) Start added in v1.2.2

func (d *PushDelegate) Start(stop chan struct{})

func (*PushDelegate) TokenOnline added in v1.2.2

func (d *PushDelegate) TokenOnline(on *pbs.WSOnline)

type Service

type Service struct {
	IMP2pWorker *worker.TopicWorker
	// contains filtered or unexported fields
}

func Inst

func Inst() *Service

func (*Service) DebugInfo

func (ws *Service) DebugInfo(online, local bool, usr string) string

func (*Service) ImmediateMsgForP2pNetwork

func (ws *Service) ImmediateMsgForP2pNetwork(w *worker.TopicWorker)

func (*Service) OnOffLineForP2pNetwork

func (ws *Service) OnOffLineForP2pNetwork(w *worker.TopicWorker)

func (*Service) ProcOnlineMapRequestFromP2pNetwork added in v1.2.2

func (ws *Service) ProcOnlineMapRequestFromP2pNetwork(stream network.Stream)

func (*Service) ShutDown

func (ws *Service) ShutDown()

func (*Service) StartService

func (ws *Service) StartService(nodeID string)

func (*Service) SyncOnlineSetFromPeerNodes

func (ws *Service) SyncOnlineSetFromPeerNodes(stream network.Stream) error

type UserLevel added in v1.2.2

type UserLevel int8
const (
	FreeUser UserLevel = iota
	Bronze
	Silver
	Gold
)

func (UserLevel) CheckMessage added in v1.2.2

func (ul UserLevel) CheckMessage(msg *pbs.WsMsg) (*pbs.WsMsg, bool)

func (UserLevel) String added in v1.2.2

func (ul UserLevel) String() string

type UserTable

type UserTable struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*UserTable) AllUid

func (ut *UserTable) AllUid() []string

func (*UserTable) DumpContent

func (ut *UserTable) DumpContent() string

type WsMsgBuffer

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

Jump to

Keyboard shortcuts

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