netmsg

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 5 Imported by: 0

README

cmd := ctx.ParamStr("cmd")
sessionId := netmsg.NewSession()
netmsg.SendMsg(sessionId, cmd, func(param interface{}) interface{} { //params=SendMsg第二个参数
	return gm_module.HandleCMD(param.(string)) //异步返回等待消息管道
})
ret := netmsg.RecMsg(sessionId).(*netmsg.PipeMsg) //阻塞等待消息返回

Documentation

Index

Constants

View Source
const (
	DEFAULT_ACCESS_TIMEOUT       = 60 * time.Second
	RetCode_CODE_TIME_OUT  int32 = 10000
)

Variables

This section is empty.

Functions

func AsyncSendMsg

func AsyncSendMsg(excutor taskexcutor.Excutor, data interface{}, callback CallBackMsg, taskid interface{}) error

func DelSession

func DelSession(id int64)

func NewSession

func NewSession() int64

func RecMsg

func RecMsg(sId int64) interface{}

func RecMsgWithTime

func RecMsgWithTime(sId int64, timeout time.Duration) interface{}

func SendMsg

func SendMsg(excutor taskexcutor.Excutor, sessionid int64, data interface{}, callback CallBackMsg, taskid interface{}) error

Types

type CallBackMsg

type CallBackMsg func(interface{}) interface{}

事件回调

type Handler

type Handler struct {
	Pipe chan *PipeMsg
}

type Msg

type Msg struct {
	SessionId int64
	Data      interface{}
	CallBack  CallBackMsg
}

type PipeMsg

type PipeMsg struct {
	Data  interface{}
	Error error
}

type Session

type Session struct {
	Id     int64
	Hander *Handler
}

func GetSession

func GetSession(id int64) *Session

func (*Session) Read

func (s *Session) Read(timeout time.Duration) *PipeMsg

func (*Session) Write

func (s *Session) Write(data *PipeMsg)

Jump to

Keyboard shortcuts

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