handler

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PayloadType_PeerClient   = "peerClient"
	PayloadType_PeerEndpoint = "peerEndpoint"
	PayloadType_ChainApp     = "chainApp"
	PayloadType_DataBlock    = "dataBlock"
	PayloadType_ConsensusLog = "consensusLog"

	PayloadType_PeerClients   = "peerClients"
	PayloadType_PeerEndpoints = "peerEndpoints"
	PayloadType_ChainApps     = "chainApps"
	PayloadType_DataBlocks    = "dataBlocks"

	PayloadType_String = "string"
	PayloadType_Map    = "map"
)
View Source
const CompressLimit = 2048
View Source
const PayloadLimit = 32 * 1024

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(msg *msg1.ChainMessage) (*msg1.ChainMessage, error)

func Encrypt

func Encrypt(msg *msg1.ChainMessage) (*msg1.ChainMessage, error)

func Error

func Error(msgType msgtype.MsgType, err error) *msg1.ChainMessage

func GetPublicKey

func GetPublicKey(targetPeerId string) (*crypto.Key, error)

func Ok

func Ok(msgType msgtype.MsgType) *msg1.ChainMessage

func ReceiveValidate

func ReceiveValidate(msg *msg1.ChainMessage) error

* 在接收解密处理后校验,然后再进行业务处理

func RegistChainMessageHandler

func RegistChainMessageHandler(msgType string,

	sendHandler func(chainMessage *msg.ChainMessage) (*msg.ChainMessage, error),
	receiveHandler func(chainMessage *msg.ChainMessage) (*msg.ChainMessage, error),
	responseHandler func(chainMessage *msg.ChainMessage) error)

* 注册各action的消息处理函数

func Response

func Response(msgType msgtype.MsgType, payload interface{}) *msg1.ChainMessage

func ResponseValidate

func ResponseValidate(msg *msg1.ChainMessage) error

* 在发送回应数据前校验,然后再加密等处理

func SendValidate

func SendValidate(msg *msg1.ChainMessage) error

* 在发送前校验各字段,然后再加密等处理

func SetResponse

func SetResponse(request *msg1.ChainMessage, response *msg1.ChainMessage)

Types

type ChainMessageHandler

type ChainMessageHandler struct {
	MsgType string
	/**
	接收函数,返回的整数:0,不关闭流;1,发送完处理结果后关闭写流,不能再写;2,发送完处理结果后重置流,不能读写,完全关闭
	*/
	ReceiveHandler  func(chainMessage *msg.ChainMessage) (*msg.ChainMessage, error)
	SendHandler     func(chainMessage *msg.ChainMessage) (*msg.ChainMessage, error)
	ResponseHandler func(chainMessage *msg.ChainMessage) error
}

func GetChainMessageHandler

func GetChainMessageHandler(msgType string) (*ChainMessageHandler, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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