sess

package
v0.0.0-...-135b9b9 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MaxMsgBuffer 消息最大长度
	MaxMsgBuffer = 100 * 1024
)
View Source
const (

	// MsgHeadSize consist message length , compression type and message id
	MsgHeadSize = 6
)

Variables

This section is empty.

Functions

func DecodeMsg

func DecodeMsg(flag byte, buf []byte) (msgdef.IMsg, error)

DecodeMsg 返回消息名称及反序列化后的消息对象

func DecryptData

func DecryptData(buf []byte) []byte

DecryptData 解密算法

func Dial

func Dial(protocal string, addr string) (iserver.ISess, error)

Dial 创建一个连接

func EncodeMsg

func EncodeMsg(msg msgdef.IMsg, buf []byte, forceNoCompress bool) ([]byte, error)

func EncodeMsgWithEncrypt

func EncodeMsgWithEncrypt(msg msgdef.IMsg, buf []byte, forceNoCompress bool, encryptEnabled bool) ([]byte, error)

EncodeMsg 序列化消息

func EncryptData

func EncryptData(buf []byte) []byte

EncryptData 加密算法

func GetMsgID

func GetMsgID(buf []byte) uint16

GetMsgID 获取消息ID

Types

type ARQNetSrv

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

ARQNetSrv 网络服务器

type IConnNotify

type IConnNotify interface {
	// contains filtered or unexported methods
}

IConnNotify 连接状态发生改变得到通知

type IConnReceiver

type IConnReceiver interface {
	// contains filtered or unexported methods
}

IConnReceiver 连接接收

type IMsgServer

type IMsgServer interface {
	msghandler.IMsgHandlers
	IConnReceiver

	Start() error
	Close()
	MainLoop()
	GetSession(id uint64) iserver.ISess
	Count() int
	SetEncryptEnabled()
}

IMsgServer 消息服务器接口

func NewMsgServer

func NewMsgServer(protocal string, addr string, maxConns int) IMsgServer

NewMsgServer 创建一个消息监听器

type INetSrv

type INetSrv interface {
	// contains filtered or unexported methods
}

INetSrv 网络监听

type MsgServer

type MsgServer struct {
	msghandler.IMsgHandlers
	*SessMgr
	INetSrv
	// contains filtered or unexported fields
}

MsgServer 消息服务器

func (*MsgServer) Close

func (srv *MsgServer) Close()

Close 关闭服务器

func (*MsgServer) GetSession

func (srv *MsgServer) GetSession(id uint64) iserver.ISess

GetSession 获取一个Sess对象

func (*MsgServer) MainLoop

func (srv *MsgServer) MainLoop()

MainLoop 每帧调用

func (*MsgServer) SetEncryptEnabled

func (srv *MsgServer) SetEncryptEnabled()

SetEncryptEnabled 是否加密

func (*MsgServer) Start

func (srv *MsgServer) Start() error

Start 启动服务器

type NetSess

type NetSess struct {
	msghandler.IMsgHandlers
	// contains filtered or unexported fields
}

NetSess 代表一个网络连接

func (*NetSess) Close

func (sess *NetSess) Close()

Close 关闭

func (*NetSess) FetchBacklog

func (sess *NetSess) FetchBacklog(o iserver.ISess)

FetchBacklog 获取积压消息

func (*NetSess) FlushBacklog

func (sess *NetSess) FlushBacklog()

FlushBacklog 刷新积压消息

func (*NetSess) GetID

func (sess *NetSess) GetID() uint64

GetID 获取ID

func (*NetSess) GetServerType

func (sess *NetSess) GetServerType() uint8

GetID 获取servertype

func (*NetSess) IsClosed

func (sess *NetSess) IsClosed() bool

IsClosed 返回sess是否已经关闭

func (*NetSess) IsVertified

func (sess *NetSess) IsVertified() bool

IsVertified 是否验证的连接

func (*NetSess) RemoteAddr

func (sess *NetSess) RemoteAddr() string

RemoteAddr 远程地址

func (*NetSess) Send

func (sess *NetSess) Send(msg msgdef.IMsg)

Send 发送消息

func (*NetSess) SendRaw

func (sess *NetSess) SendRaw(rawMsg []byte)

SendRaw 发送原始消息

func (*NetSess) SetID

func (sess *NetSess) SetID(id uint64)

SetID 设置ID

func (*NetSess) SetMsgHandler

func (sess *NetSess) SetMsgHandler(handler msghandler.IMsgHandlers)

SetMsgHandler 设置消息处理器

func (*NetSess) SetServerType

func (sess *NetSess) SetServerType(servertype uint8)

SetID 设置servertype

func (*NetSess) SetVertify

func (sess *NetSess) SetVertify()

SetVertify 设置已经验证

func (*NetSess) Start

func (sess *NetSess) Start()

Start 验证完成

func (*NetSess) Touch

func (sess *NetSess) Touch()

Touch 记录心跳状态

type RawMsg

type RawMsg struct {
	MsgID int
	Msg   []byte
}

RawMsg 对象

type SessMgr

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

SessMgr 管理 Sess

func (*SessMgr) Count

func (mgr *SessMgr) Count() int

Count 获取Sess的数量

func (*SessMgr) SetEncryptEnabled

func (mgr *SessMgr) SetEncryptEnabled()

SetEncryptEnabled 设置加密模式

Jump to

Keyboard shortcuts

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