proto

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt

func BytesToInt(raw []byte) int

func IntToBytes

func IntToBytes(raw int) []byte

Types

type AuthCallback added in v0.0.3

type AuthCallback func(cbStruct AuthCbStruct) bool

type AuthCbStruct added in v0.0.3

type AuthCbStruct struct {
	// /path
	Path string
	// http://example.com
	Origin string
}

type MsgStruct

type MsgStruct struct {
	Header []byte
	Body   []byte
	// contains filtered or unexported fields
}

MsgStruct 消息结构体 lenHeader lenBody Header Body len均为32位长度 4bytes

func NewMsgStructFromBytes

func NewMsgStructFromBytes(raw []byte) *MsgStruct

func NewMsgStructFromParam

func NewMsgStructFromParam(header string, body string) *MsgStruct

func (*MsgStruct) FromBytes

func (m *MsgStruct) FromBytes(raw []byte) error

func (*MsgStruct) GetBody

func (m *MsgStruct) GetBody() string

func (*MsgStruct) GetHeader

func (m *MsgStruct) GetHeader() string

func (*MsgStruct) ToBytes

func (m *MsgStruct) ToBytes() []byte

type Session

type Session interface {
	// ID 获取SessionId
	ID() string
	// On 自定义事件回调
	On(header string, cb SessionCallback)
	// Emit 发送消息
	Emit(header string, body string) error
	// Close 关闭连接
	Close()
}

type SessionCallback

type SessionCallback func(cbStruct SessionCbStruct)

type SessionCbStruct

type SessionCbStruct struct {
	Session   Session
	MsgStruct *MsgStruct
	SessionId string
	Msg       string
}

type Signal

type Signal interface {
	// OnConnect 客户端连接回调,阻塞
	OnConnect(cb SignalCallback)
	// OnAuth 客户端认证,返回true代表通过,阻塞
	// connect后执行
	OnAuth(callback AuthCallback)
	// OnClose 连接断开回调
	OnClose(cb SignalCallback)
	// Run 运行signal server
	Run() error
}

type SignalCallback

type SignalCallback func(session Session)

Jump to

Keyboard shortcuts

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