relay

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRelayPacketCrack       = errors.New("invalid relay packet format")
	ErrUnknownPassThroughKind = errors.New("Unknown PassThrough kind")
)
View Source
var (
	ErrInvalidPeerSession = errors.New("Require valid cellnet.Session or cellnet.TCPConnector")
)

Functions

func Relay

func Relay(sesDetector, payload, passThrough interface{}) error

sesDetector: 提供要发送到的目标session, 传输msg消息,透传passThroughData

func ResoleveInboundEvent

func ResoleveInboundEvent(inputEvent cellnet.Event) (ouputEvent cellnet.Event, handled bool, err error)

处理入站的relay消息

func ResolveOutboundEvent

func ResolveOutboundEvent(inputEvent cellnet.Event) (handled bool, err error)

处理relay.Relay出站消息的日志

func SetBroadcaster

func SetBroadcaster(callback BroadcasterFunc)

设置广播函数, 回调时,按对应Peer/Session所在的队列中调用

Types

type BroadcasterFunc

type BroadcasterFunc func(event *RecvMsgEvent)

type RecvMsgEvent

type RecvMsgEvent struct {
	Ses cellnet.Session
	Msg interface{}

	PassThrough interface{}
}

func (*RecvMsgEvent) Message

func (self *RecvMsgEvent) Message() interface{}

func (*RecvMsgEvent) PassThroughAsInt64

func (self *RecvMsgEvent) PassThroughAsInt64() int64

func (*RecvMsgEvent) PassThroughAsInt64Slice

func (self *RecvMsgEvent) PassThroughAsInt64Slice() []int64

func (*RecvMsgEvent) Reply

func (self *RecvMsgEvent) Reply(msg interface{})

消息原路返回

func (*RecvMsgEvent) Session

func (self *RecvMsgEvent) Session() cellnet.Session

type RelayACK

type RelayACK struct {
	PayloadMsgID uint16
	Payload      []byte // 用户原消息

	PassThroughKind  uint8
	PassThroughMsgID uint16
	PassThrough      []byte // 透传数据
}

func (*RelayACK) Decode

func (self *RelayACK) Decode() (payload, passThrough interface{}, err error)

func (*RelayACK) Encode

func (self *RelayACK) Encode(payload, passThrough interface{}) (err error)

func (*RelayACK) String

func (self *RelayACK) String() string

Jump to

Keyboard shortcuts

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