protox

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 11 Imported by: 3

Documentation

Overview

Package protox Created by xuzhuoxi on 2019-02-26. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-02-12. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-20. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-18. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-21. @author xuzhuoxi

Package protox Create on 2023/8/6 @author xuzhuoxi

Package protox Create on 2023/7/22 @author xuzhuoxi

Package protox Create on 2023/8/6 @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-19. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-19. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-05-18. @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-03-22. @author xuzhuoxi

Package protox Create on 2023/7/20 @author xuzhuoxi

Package protox Create on 2023/7/20 @author xuzhuoxi

Package protox Created by xuzhuoxi on 2019-02-26. @author xuzhuoxi

Index

Constants

View Source
const (
	// CodeSuc 成功
	CodeSuc int32 = 0
	// CodeProtoFail 协议错误-协议不存在
	CodeProtoFail int32 = 1
	// CodeArgs 参数错误
	CodeArgs int32 = 2
	// CodeInternal 服务器内部错误
	CodeInternal int32 = 3
	// CodeDbQuery 数据库执行错误
	CodeDbQuery int32 = 4
	// CodeTimeout 请求超时
	CodeTimeout int32 = 5
	// CodeRight 权限不足
	CodeRight int32 = 6
	// CodeStatus 状态不匹配
	CodeStatus int32 = 7
	// CodeRepeat 请求重复
	CodeRepeat int32 = 8
	// CodeFrequent 请求过于频繁
	CodeFrequent int32 = 9
	// CodeOther 其它错误
	CodeOther int32 = 10
)

Variables

View Source
var (
	DefaultRequestPool  = NewPoolExtensionRequest()
	DefaultResponsePool = NewPoolExtensionResponse()
	DefaultNotifyPool   = NewPoolExtensionNotify()
)

Functions

func SetJsonMarshalHandler added in v1.0.4

func SetJsonMarshalHandler(handler func(v interface{}) ([]byte, error))

Types

type ExtensionHandlerBinaryParam

type ExtensionHandlerBinaryParam func(resp IExtensionResponse, req IExtensionBinaryRequest)

ExtensionHandlerBinaryParam Extension响应函数-二进制参数

type ExtensionHandlerNoneParam

type ExtensionHandlerNoneParam func(resp IExtensionResponse, req IExtensionRequest)

ExtensionHandlerNoneParam Extension响应函数-无参数

type ExtensionHandlerObjectParam

type ExtensionHandlerObjectParam func(resp IExtensionResponse, req IExtensionObjectRequest)

ExtensionHandlerObjectParam Extension响应函数-具体对象参数

type ExtensionHandlerStringParam added in v1.0.4

type ExtensionHandlerStringParam func(resp IExtensionResponse, req IExtensionStringRequest)

ExtensionHandlerStringParam Extension响应函数-字符串参数

type ExtensionManager

type ExtensionManager struct {
	HandlerContainer   netx.IPackHandlerContainer
	ExtensionContainer IProtocolExtensionContainer
	SockSender         netx.ISockSender

	Logger       logx.ILogger
	AddressProxy netx.IAddressProxy
	Mutex        sync.RWMutex

	ExtensionManagerCustomizeSupport
}

func NewExtensionManager

func NewExtensionManager() *ExtensionManager

func (*ExtensionManager) DisableExtension

func (m *ExtensionManager) DisableExtension(name string)

func (*ExtensionManager) DisableExtensions

func (m *ExtensionManager) DisableExtensions()

func (*ExtensionManager) DoRequest

func (m *ExtensionManager) DoRequest(extension IProtocolExtension, request IExtensionRequest, response IExtensionResponse)

func (*ExtensionManager) EnableExtension

func (m *ExtensionManager) EnableExtension(name string)

func (*ExtensionManager) EnableExtensions

func (m *ExtensionManager) EnableExtensions()

func (*ExtensionManager) GetProtocolExtension

func (m *ExtensionManager) GetProtocolExtension(eName string) (pe IProtocolExtension, ok bool)

func (*ExtensionManager) GetRecycleParams added in v1.0.4

func (m *ExtensionManager) GetRecycleParams(extension IProtocolExtension, senderAddress string, name string, pid string, uid string, data [][]byte) (resp IExtensionResponse, req IExtensionRequest)

GetRecycleParams 构造响应参数

func (*ExtensionManager) GetRecycleRequest added in v1.0.4

func (m *ExtensionManager) GetRecycleRequest(extension IProtocolExtension, senderAddress string, name string, pid string, uid string, data [][]byte) (req IExtensionRequest)

GetRecycleRequest 获取可回收的请求结构

func (*ExtensionManager) GetRecycleResponse added in v1.0.4

func (m *ExtensionManager) GetRecycleResponse(extension IProtocolExtension, senderAddress string, name string, pid string, uid string, data [][]byte) (resp IExtensionResponse)

GetRecycleResponse 构造响应参数

func (*ExtensionManager) InitManager

func (m *ExtensionManager) InitManager(handlerContainer netx.IPackHandlerContainer, extensionContainer IProtocolExtensionContainer,
	sockSender netx.ISockSender)

func (*ExtensionManager) OnMessageUnpack

func (m *ExtensionManager) OnMessageUnpack(msgData []byte, senderAddress string, other interface{}) bool

OnMessageUnpack 消息处理入口,这里是并发方法 并发注意:本方法是否并发,取决于SockServer的并发性 在netx中,TCP,Quic,WebSocket为并发响应,UDP为非并发响应 msgData非共享的,但在parsePackMessage后这部分数据会发生变化

func (*ExtensionManager) ParseMessage

func (m *ExtensionManager) ParseMessage(msgBytes []byte) (extName string, pid string, uid string, data [][]byte)

ParseMessage block0 : eName utf8 block1 : pid utf8 block2 : uid utf8 block3 : data [][]byte [n]其它信息

func (*ExtensionManager) SaveExtension

func (m *ExtensionManager) SaveExtension(name string)

func (*ExtensionManager) SaveExtensions

func (m *ExtensionManager) SaveExtensions()

func (*ExtensionManager) SetAddressProxy

func (m *ExtensionManager) SetAddressProxy(proxy netx.IAddressProxy)

func (*ExtensionManager) SetLogger

func (m *ExtensionManager) SetLogger(logger logx.ILogger)

func (*ExtensionManager) StartManager

func (m *ExtensionManager) StartManager()

func (*ExtensionManager) StopManager

func (m *ExtensionManager) StopManager()

func (*ExtensionManager) Verify

func (m *ExtensionManager) Verify(name string, pid string, uid string) (e IProtocolExtension, rsCode int32)

type ExtensionManagerCustomizeSupport

type ExtensionManagerCustomizeSupport struct {
	FuncStartOnPack     FuncStartOnPack
	FuncParseMessage    FuncParseMessage
	FuncVerify          FuncVerify
	FuncStartOnRequest  FuncStartOnRequest
	FuncFinishOnRequest FuncFinishOnRequest
}

func (*ExtensionManagerCustomizeSupport) CustomFinishOnRequest

func (o *ExtensionManagerCustomizeSupport) CustomFinishOnRequest(resp IExtensionResponse, req IExtensionRequest)

func (*ExtensionManagerCustomizeSupport) CustomParseMessage

func (o *ExtensionManagerCustomizeSupport) CustomParseMessage(msgBytes []byte) (name string, pid string, uid string, data [][]byte)

func (*ExtensionManagerCustomizeSupport) CustomStartOnPack

func (o *ExtensionManagerCustomizeSupport) CustomStartOnPack(senderAddress string)

func (*ExtensionManagerCustomizeSupport) CustomStartOnRequest

func (o *ExtensionManagerCustomizeSupport) CustomStartOnRequest(resp IExtensionResponse, req IExtensionRequest)

func (*ExtensionManagerCustomizeSupport) CustomVerify

func (o *ExtensionManagerCustomizeSupport) CustomVerify(name string, pid string, uid string) (e IProtocolExtension, rsCode int32)

func (*ExtensionManagerCustomizeSupport) SetCustom

func (o *ExtensionManagerCustomizeSupport) SetCustom(funcStartOnPack FuncStartOnPack, funcParse FuncParseMessage, funcVerify FuncVerify, funcStart FuncStartOnRequest, funcFinish FuncFinishOnRequest)

func (*ExtensionManagerCustomizeSupport) SetCustomFinishOnRequestFunc

func (o *ExtensionManagerCustomizeSupport) SetCustomFinishOnRequestFunc(funcFinish FuncFinishOnRequest)

func (*ExtensionManagerCustomizeSupport) SetCustomParseFunc

func (o *ExtensionManagerCustomizeSupport) SetCustomParseFunc(funcParse FuncParseMessage)

func (*ExtensionManagerCustomizeSupport) SetCustomStartOnPackFunc

func (o *ExtensionManagerCustomizeSupport) SetCustomStartOnPackFunc(funcStartOnPack FuncStartOnPack)

func (*ExtensionManagerCustomizeSupport) SetCustomStartOnRequestFunc

func (o *ExtensionManagerCustomizeSupport) SetCustomStartOnRequestFunc(funcStart FuncStartOnRequest)

func (*ExtensionManagerCustomizeSupport) SetCustomVerifyFunc

func (o *ExtensionManagerCustomizeSupport) SetCustomVerifyFunc(funcVerify FuncVerify)

type ExtensionParamType

type ExtensionParamType int

ExtensionParamType Extension响应参数类型

const (
	None ExtensionParamType = iota
	Binary
	String
	Object
)

type ExtensionProtoInfo

type ExtensionProtoInfo struct {
	ProtoId          string
	ParamType        ExtensionParamType
	ExtensionHandler interface{}

	ParamHandler    IProtocolParamsHandler
	ReqParamFactory ParamFactory
}

ExtensionProtoInfo 协议定义

type FuncFinishOnRequest

type FuncFinishOnRequest func(resp IExtensionResponse, req IExtensionRequest)

FuncFinishOnRequest 响应完成

type FuncParseMessage

type FuncParseMessage func(msgBytes []byte) (name string, pid string, uid string, data [][]byte)

FuncParseMessage 解释二进制数据

type FuncStartOnPack

type FuncStartOnPack func(senderAddress string)

FuncStartOnPack 响应入口

type FuncStartOnRequest

type FuncStartOnRequest func(resp IExtensionResponse, req IExtensionRequest)

FuncStartOnRequest 响应开始

type FuncVerify

type FuncVerify func(name string, pid string, uid string) (e IProtocolExtension, rsCode int32)

FuncVerify 消息处理入口,这里是并发方法

type GoroutineExtensionSupport

type GoroutineExtensionSupport struct {
	MaxGoroutine int
}

func NewGoroutineExtensionSupport

func NewGoroutineExtensionSupport(MaxGo int) GoroutineExtensionSupport

func (*GoroutineExtensionSupport) MaxGo

func (s *GoroutineExtensionSupport) MaxGo() int

type IAfterRequestExtension

type IAfterRequestExtension interface {
	// AfterRequest
	// 响应结束前的一些处理
	AfterRequest(resp IExtensionResponse, req IExtensionRequest)
}

type IBeforeRequestExtension

type IBeforeRequestExtension interface {
	// BeforeRequest
	// 执行响应前的一些处理
	BeforeRequest(req IExtensionRequest)
}

type IExtensionBinaryRequest

type IExtensionBinaryRequest interface {
	IExtensionRequest
	// BinaryData
	// RequestBinaryData
	// 请求的参数数据(二进制)
	BinaryData() [][]byte
}

IExtensionBinaryRequest 数据参数为二进制的请求对象参数集合接口

type IExtensionManager

type IExtensionManager interface {
	logx.ILoggerSetter
	netx.IAddressProxySetter

	// InitManager
	// 初始化
	// handlerContainer: 解包处理
	// extensionContainer: 服务扩展
	// sockSender: 消息发送器
	InitManager(handlerContainer netx.IPackHandlerContainer, extensionContainer IProtocolExtensionContainer, sockSender netx.ISockSender)

	// StartManager
	// 开始运行
	StartManager()
	// StopManager
	// 停止运行
	StopManager()

	// SaveExtension
	// 保存指定Extension的临时数据
	SaveExtension(name string)
	// SaveExtensions
	// 保存全部Extension的临时数据
	SaveExtensions()

	// EnableExtension
	// 启用指定Extension的临时数据
	EnableExtension(name string)
	// EnableExtensions
	// 启用全部Extension的临时数据
	EnableExtensions()
	// DisableExtension
	// 禁用指定Extension的临时数据
	DisableExtension(name string)
	// DisableExtensions
	// 禁用全部Extension的临时数据
	DisableExtensions()

	// OnMessageUnpack
	// 消息处理入口,这里是并发方法
	OnMessageUnpack(msgData []byte, senderAddress string, other interface{}) bool
	// DoRequest
	// 消息处理入口,这里是并发方法
	DoRequest(extension IProtocolExtension, req IExtensionRequest, resp IExtensionResponse)
}

IExtensionManager Extension管理接口

func NewIExtensionManager

func NewIExtensionManager() IExtensionManager

type IExtensionManagerCustomizeSetting

type IExtensionManagerCustomizeSetting interface {
	// SetCustomStartOnPackFunc
	// 设置自定义响应开始行为
	SetCustomStartOnPackFunc(funcStartOnPack FuncStartOnPack)
	// SetCustomParseFunc
	// 设置自定义数据解释行为
	SetCustomParseFunc(funcParse FuncParseMessage)
	// SetCustomVerifyFunc
	// 设置自定义验证
	SetCustomVerifyFunc(funcVerify FuncVerify)
	// SetCustomStartOnRequestFunc
	// 设置自定义响应前置行为
	SetCustomStartOnRequestFunc(funcStart FuncStartOnRequest)
	// SetCustomFinishOnRequestFunc
	// 设置自定义响应完成行为
	SetCustomFinishOnRequestFunc(funcFinish FuncFinishOnRequest)
	// SetCustom
	// 设置自定义行为
	SetCustom(funcStartOnPack FuncStartOnPack, funcParse FuncParseMessage, funcVerify FuncVerify, funcStart FuncStartOnRequest, funcFinish FuncFinishOnRequest)
}

type IExtensionManagerCustomizeSupport

type IExtensionManagerCustomizeSupport interface {
	CustomStartOnPack(senderAddress string)
	CustomParseMessage(msgBytes []byte) (name string, pid string, uid string, data [][]byte)
	CustomVerify(name string, pid string, uid string) (e IProtocolExtension, rsCode int32)
	CustomStartOnRequest(resp IExtensionResponse, req IExtensionRequest)
	CustomFinishOnRequest(resp IExtensionResponse, req IExtensionRequest)
}

type IExtensionNotify added in v1.0.4

type IExtensionNotify interface {
	IProtoReturnMessage
	SetCodingHandler(encodeHandler encodingx.ICodingHandler)
}

type IExtensionObjectRequest

type IExtensionObjectRequest interface {
	IExtensionRequest
	// ObjectData
	// 请求的参数数据(具体数据)
	ObjectData() []interface{}
}

IExtensionObjectRequest 数据参数为结构体的请求对象参数集合接口

type IExtensionRequest

type IExtensionRequest interface {
	IProtoHeader
	// DataSize 数据长度
	DataSize() int
	// SetRequestData
	// 设置集合数据信息
	SetRequestData(paramType ExtensionParamType, paramHandler IProtocolParamsHandler, data [][]byte)
}

IExtensionRequest 请求对象参数集合接口

type IExtensionResponse

type IExtensionResponse interface {
	IProtoReturnMessage
	// SetParamInfo
	// 设置参数类型与处理器
	SetParamInfo(paramType ExtensionParamType, paramHandler IProtocolParamsHandler)
	// SetResultCode
	// 设置返回状态码
	SetResultCode(rsCode int32)
	// SendResponse
	// 根据设置好的参数响应
	SendResponse() error
	// SendResponseTo
	// 根据设置好的参数响应到其它用户
	SendResponseTo(interruptOnErr bool, clientIds ...string) error
	// SendNotify
	// 根据设置好的参数响应
	SendNotify(eName string, notifyPId string) error
	// SendNotifyTo
	// 根据设置好的参数响应到其它用户
	SendNotifyTo(eName string, notifyPId string, interruptOnErr bool, clientIds ...string) error
	// contains filtered or unexported methods
}

IExtensionResponse 响应对象参数集合接口

type IExtensionResponseSettings added in v1.0.4

type IExtensionResponseSettings interface {
	netx.IAddressProxySetter
	netx.ISockSenderSetter
}

type IExtensionStringRequest added in v1.0.4

type IExtensionStringRequest interface {
	IExtensionRequest
	// StringData
	// 请求的参数数据(String)
	StringData() []string
}

IExtensionStringRequest 数据参数为Json的请求对象参数集合接口

type IGoroutineExtension

type IGoroutineExtension interface {
	// MaxGo
	// 最大并发处理个数
	MaxGo() int
}

type IPoolExtensionNotify added in v1.0.4

type IPoolExtensionNotify interface {
	// Register 注册创建方法
	Register(newFunc func() IExtensionNotify)
	// GetInstance 获取一个实例
	GetInstance() IExtensionNotify
	// Recycle 回收一个实例
	Recycle(instance IExtensionNotify) bool
}

IPoolExtensionNotify 通知参数集的对象池接口

func NewPoolExtensionNotify added in v1.0.4

func NewPoolExtensionNotify() IPoolExtensionNotify

type IPoolExtensionRequest

type IPoolExtensionRequest interface {
	// Register 注册创建方法
	Register(newFunc func() IExtensionRequest)
	// GetInstance 获取一个实例
	GetInstance() IExtensionRequest
	// Recycle 回收一个实例
	Recycle(instance IExtensionRequest) bool
}

IPoolExtensionRequest 请求参数集的对象池接口

func NewPoolExtensionRequest

func NewPoolExtensionRequest() IPoolExtensionRequest

type IPoolExtensionResponse

type IPoolExtensionResponse interface {
	// Register 注册创建方法
	Register(newFunc func() IExtensionResponse)
	// GetInstance 获取一个实例
	GetInstance() IExtensionResponse
	// Recycle 回收一个实例
	Recycle(instance IExtensionResponse) bool
}

IPoolExtensionResponse 响应参数集的对象池接口

func NewPoolExtensionResponse

func NewPoolExtensionResponse() IPoolExtensionResponse

type IProtoHeader added in v1.0.4

type IProtoHeader interface {
	// ProtoGroup
	// 协议分组
	ProtoGroup() string
	// ProtoId
	// 协议标识
	ProtoId() string
	// ClientId
	// 客户端标识
	ClientId() string
	// ClientAddress
	// 客户端地址
	ClientAddress() string
	// SetHeader
	// 设置参数头信息
	SetHeader(extensionName string, protoId string, clientId string, clientAddress string)
	// GetHeaderInfo 取头信息
	GetHeaderInfo() IProtoHeader
}

IProtoHeader 协议参数头接口

type IProtoMessageParser

type IProtoMessageParser interface {
}

type IProtoReturnMessage added in v1.0.4

type IProtoReturnMessage interface {
	IProtoHeader
	// PrepareData
	// 准备设置回复参数
	PrepareData()
	// AppendLen
	// 追加参数 - 长度值
	AppendLen(ln int) error
	// AppendBinary
	// 追加参数 - 字节数组
	AppendBinary(data ...[]byte) error
	// AppendCommon
	// 追加参数 - 通用数据类型
	AppendCommon(data ...interface{}) error
	// AppendString
	// 追加返回- 字符串
	AppendString(data ...string) error
	// AppendJson
	// 追加返回- Json字符串 或 可序列化的Struct
	AppendJson(data ...interface{}) error
	// AppendObject
	// 追加参数
	AppendObject(data ...interface{}) error
	// GenMsgBytes
	// 生成消息
	GenMsgBytes() (msg []byte, err error)
}

type IProtocolExtension

type IProtocolExtension interface {
	extendx.IExtension
	extendx.IInitExtension
	// CheckProtocolId
	// 检查ProtoId是否为被当前扩展支持
	CheckProtocolId(protoId string) bool
	// GetParamInfo
	// 检查ProtoId对应的设置
	GetParamInfo(protoId string) (paramType ExtensionParamType, handler IProtocolParamsHandler)
}

type IProtocolExtensionContainer

type IProtocolExtensionContainer interface {
	extendx.IExtensionContainer
	// InitExtensions
	// 初始化全部Extension
	InitExtensions() []error
	// DestroyExtensions
	// 销毁全部Extension
	DestroyExtensions() []error

	// SaveExtensions
	// 保存
	SaveExtensions() []error
	// SaveExtension
	// 保存指定
	SaveExtension(name string) error

	// EnableExtensions
	// 设置启用全部Extension
	EnableExtensions(enable bool) []error
	// EnableExtension
	// 设置启用Extension
	EnableExtension(name string, enable bool) error
}

func NewIProtocolExtensionContainer

func NewIProtocolExtensionContainer() IProtocolExtensionContainer

type IProtocolParamsHandler

type IProtocolParamsHandler interface {
	// SetCodingHandler
	// 设置编解码器
	SetCodingHandler(handler encodingx.ICodingHandler)
	// HandleRequestParam
	// 处理请求参数转换:二进制->具体数据
	HandleRequestParam(data []byte) interface{}
	// HandleRequestParams
	// 处理请求参数转换:二进制->具体数据(批量)
	HandleRequestParams(data [][]byte) []interface{}
	// HandleResponseParam
	// 处理响应参数转换:具体数据->二进制
	HandleResponseParam(data interface{}) []byte
	// HandleResponseParams
	// 处理响应参数转换:具体数据->二进制(批量)
	HandleResponseParams(data []interface{}) [][]byte
}

IProtocolParamsHandler 协议参数处理器接口 要求:并发安全

func NewProtoObjectParamsHandler added in v1.0.4

func NewProtoObjectParamsHandler(factory ParamFactory, handler encodingx.ICodingHandler) IProtocolParamsHandler

type IRequestExtension

type IRequestExtension interface {
	// OnRequest
	// 请求响应
	OnRequest(resp IExtensionResponse, req IExtensionRequest)
}

type IRequestExtensionSetter

type IRequestExtensionSetter interface {
	// SetRequestHandler
	// 设置请求响应处理(无参数)
	SetRequestHandler(protoId string, handler ExtensionHandlerNoneParam)
	// SetRequestHandlerBinary
	// 设置请求响应处理(字节数组参数)
	SetRequestHandlerBinary(protoId string, handler ExtensionHandlerBinaryParam)
	// SetRequestHandlerString
	// 设置请求响应处理(字符串参数)
	SetRequestHandlerString(protoId string, handler ExtensionHandlerStringParam)
	// SetRequestHandlerObject
	//设置请求响应处理(对象参数)
	SetRequestHandlerObject(protoId string, handler ExtensionHandlerObjectParam,
		paramOrigin interface{}, paramHandler IProtocolParamsHandler)
	// ClearRequestHandler
	// 清除设置
	ClearRequestHandler(protoId string)
}

type ParamFactory added in v1.0.4

type ParamFactory = func() interface{}

ParamFactory 通用参数构造器

type ProtoExtensionSupport added in v1.0.4

type ProtoExtensionSupport struct {
	Name          string
	ProtoIdToInfo map[string]*ExtensionProtoInfo
}

func NewProtoExtensionSupport added in v1.0.4

func NewProtoExtensionSupport(Name string) ProtoExtensionSupport

func (*ProtoExtensionSupport) CheckProtocolId added in v1.0.4

func (s *ProtoExtensionSupport) CheckProtocolId(protoId string) bool

func (*ProtoExtensionSupport) ClearRequestHandler added in v1.0.4

func (s *ProtoExtensionSupport) ClearRequestHandler(protoId string)

func (*ProtoExtensionSupport) ExtensionName added in v1.0.4

func (s *ProtoExtensionSupport) ExtensionName() string

func (*ProtoExtensionSupport) GetParamInfo added in v1.0.4

func (s *ProtoExtensionSupport) GetParamInfo(protoId string) (paramType ExtensionParamType, handler IProtocolParamsHandler)

func (*ProtoExtensionSupport) OnRequest added in v1.0.4

func (*ProtoExtensionSupport) SetRequestHandler added in v1.0.4

func (s *ProtoExtensionSupport) SetRequestHandler(protoId string, handler ExtensionHandlerNoneParam)

func (*ProtoExtensionSupport) SetRequestHandlerBinary added in v1.0.4

func (s *ProtoExtensionSupport) SetRequestHandlerBinary(protoId string, handler ExtensionHandlerBinaryParam)

func (*ProtoExtensionSupport) SetRequestHandlerObject added in v1.0.4

func (s *ProtoExtensionSupport) SetRequestHandlerObject(protoId string, handler ExtensionHandlerObjectParam,
	factory ParamFactory, codingHandler encodingx.ICodingHandler)

func (*ProtoExtensionSupport) SetRequestHandlerString added in v1.0.4

func (s *ProtoExtensionSupport) SetRequestHandlerString(protoId string, handler ExtensionHandlerStringParam)

type ProtoHeader added in v1.0.4

type ProtoHeader struct {
	PGroup   string
	PId      string
	CId      string
	CAddress string
}

func (*ProtoHeader) ClientAddress added in v1.0.4

func (h *ProtoHeader) ClientAddress() string

func (*ProtoHeader) ClientId added in v1.0.4

func (h *ProtoHeader) ClientId() string

func (*ProtoHeader) GetHeaderInfo added in v1.0.4

func (h *ProtoHeader) GetHeaderInfo() IProtoHeader

func (*ProtoHeader) ProtoGroup added in v1.0.4

func (h *ProtoHeader) ProtoGroup() string

func (*ProtoHeader) ProtoId added in v1.0.4

func (h *ProtoHeader) ProtoId() string

func (*ProtoHeader) SetHeader added in v1.0.4

func (h *ProtoHeader) SetHeader(extensionName string, protoId string, clientId string, clientAddress string)

func (*ProtoHeader) String added in v1.0.4

func (h *ProtoHeader) String() string

type ProtoObjectParamsHandler added in v1.0.4

type ProtoObjectParamsHandler struct {
	ParamFactory ParamFactory
	Handler      encodingx.ICodingHandler
}

func (*ProtoObjectParamsHandler) HandleRequestParam added in v1.0.4

func (o *ProtoObjectParamsHandler) HandleRequestParam(data []byte) interface{}

func (*ProtoObjectParamsHandler) HandleRequestParams added in v1.0.4

func (o *ProtoObjectParamsHandler) HandleRequestParams(data [][]byte) []interface{}

func (*ProtoObjectParamsHandler) HandleResponseParam added in v1.0.4

func (o *ProtoObjectParamsHandler) HandleResponseParam(data interface{}) []byte

func (*ProtoObjectParamsHandler) HandleResponseParams added in v1.0.4

func (o *ProtoObjectParamsHandler) HandleResponseParams(data []interface{}) [][]byte

func (*ProtoObjectParamsHandler) SetCodingHandler added in v1.0.4

func (o *ProtoObjectParamsHandler) SetCodingHandler(handler encodingx.ICodingHandler)

type ProtoReturnMessage added in v1.0.4

type ProtoReturnMessage struct {
	ProtoHeader
	RsCode       int32
	ParamHandler IProtocolParamsHandler
	MsgBuff      bytex.IBuffToBlock
	DataBuff     bytex.IBuffToBlock
	// contains filtered or unexported fields
}

func NewProtoReturnMessage added in v1.0.4

func NewProtoReturnMessage() *ProtoReturnMessage

func (*ProtoReturnMessage) AppendBinary added in v1.0.4

func (o *ProtoReturnMessage) AppendBinary(data ...[]byte) error

func (*ProtoReturnMessage) AppendCommon added in v1.0.4

func (o *ProtoReturnMessage) AppendCommon(data ...interface{}) error

func (*ProtoReturnMessage) AppendJson added in v1.0.4

func (o *ProtoReturnMessage) AppendJson(data ...interface{}) error

func (*ProtoReturnMessage) AppendLen added in v1.0.4

func (o *ProtoReturnMessage) AppendLen(ln int) error

func (*ProtoReturnMessage) AppendObject added in v1.0.4

func (o *ProtoReturnMessage) AppendObject(data ...interface{}) error

func (*ProtoReturnMessage) AppendString added in v1.0.4

func (o *ProtoReturnMessage) AppendString(data ...string) error

func (*ProtoReturnMessage) GenMsgBytes added in v1.0.4

func (o *ProtoReturnMessage) GenMsgBytes() (msg []byte, err error)

func (*ProtoReturnMessage) PrepareData added in v1.0.4

func (o *ProtoReturnMessage) PrepareData()

type ProtocolContainer

type ProtocolContainer struct {
	extendx.ExtensionContainer
}

func NewProtocolExtensionContainer

func NewProtocolExtensionContainer() ProtocolContainer

func (*ProtocolContainer) DestroyExtensions

func (c *ProtocolContainer) DestroyExtensions() []error

func (*ProtocolContainer) EnableExtension

func (c *ProtocolContainer) EnableExtension(name string, enable bool) error

func (*ProtocolContainer) EnableExtensions

func (c *ProtocolContainer) EnableExtensions(enable bool) []error

func (*ProtocolContainer) InitExtensions

func (c *ProtocolContainer) InitExtensions() []error

func (*ProtocolContainer) SaveExtension

func (c *ProtocolContainer) SaveExtension(name string) error

func (*ProtocolContainer) SaveExtensions

func (c *ProtocolContainer) SaveExtensions() []error

type SockNotify added in v1.0.4

type SockNotify struct {
	ProtoReturnMessage
}

func NewSockNotify added in v1.0.4

func NewSockNotify() *SockNotify

func (*SockNotify) SetCodingHandler added in v1.0.4

func (o *SockNotify) SetCodingHandler(codingHandler encodingx.ICodingHandler)

type SockRequest

type SockRequest struct {
	ProtoHeader
	ParamType ExtensionParamType
	// contains filtered or unexported fields
}

func NewSockRequest

func NewSockRequest() *SockRequest

func (*SockRequest) BinaryData

func (req *SockRequest) BinaryData() [][]byte

func (*SockRequest) DataSize added in v1.0.4

func (req *SockRequest) DataSize() int

func (*SockRequest) ObjectData

func (req *SockRequest) ObjectData() []interface{}

func (*SockRequest) SetRequestData

func (req *SockRequest) SetRequestData(paramType ExtensionParamType, paramHandler IProtocolParamsHandler, data [][]byte)

func (*SockRequest) String added in v1.0.4

func (req *SockRequest) String() string

func (*SockRequest) StringData added in v1.0.4

func (req *SockRequest) StringData() []string

type SockResponse

type SockResponse struct {
	ProtoReturnMessage
	SockSender   netx.ISockSender
	AddressProxy netx.IAddressProxy
	ParamType    ExtensionParamType
}

func NewSockResponse

func NewSockResponse() *SockResponse

func (*SockResponse) SendBinaryResponse

func (resp *SockResponse) SendBinaryResponse(data ...[]byte) error

func (*SockResponse) SendCommonResponse added in v1.0.4

func (resp *SockResponse) SendCommonResponse(data ...interface{}) error

func (*SockResponse) SendJsonResponse

func (resp *SockResponse) SendJsonResponse(data ...interface{}) error

func (*SockResponse) SendNoneResponse added in v1.0.4

func (resp *SockResponse) SendNoneResponse() error

func (*SockResponse) SendNoneResponseToClient added in v1.0.4

func (resp *SockResponse) SendNoneResponseToClient(interruptOnErr bool, clientIds ...string) error

func (*SockResponse) SendNotify added in v1.0.4

func (resp *SockResponse) SendNotify(eName string, notifyPId string) error

func (*SockResponse) SendNotifyTo added in v1.0.4

func (resp *SockResponse) SendNotifyTo(eName string, notifyPId string, interruptOnErr bool, clientIds ...string) error

func (*SockResponse) SendObjectResponse

func (resp *SockResponse) SendObjectResponse(data ...interface{}) error

func (*SockResponse) SendResponse added in v1.0.4

func (resp *SockResponse) SendResponse() error

func (*SockResponse) SendResponseTo added in v1.0.4

func (resp *SockResponse) SendResponseTo(interruptOnErr bool, clientIds ...string) error

func (*SockResponse) SendStringResponse added in v1.0.4

func (resp *SockResponse) SendStringResponse(data ...string) error

func (*SockResponse) SetAddressProxy

func (resp *SockResponse) SetAddressProxy(proxy netx.IAddressProxy)

func (*SockResponse) SetParamInfo

func (resp *SockResponse) SetParamInfo(paramType ExtensionParamType, paramHandler IProtocolParamsHandler)

func (*SockResponse) SetResultCode added in v1.0.4

func (resp *SockResponse) SetResultCode(rsCode int32)

func (*SockResponse) SetSockSender

func (resp *SockResponse) SetSockSender(sockSender netx.ISockSender)

Jump to

Keyboard shortcuts

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