netmsg

package
v0.0.0-...-29c100b Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2017 License: Apache-2.0 Imports: 4 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

Overview

Copyright 2016 zxfonline@sina.com. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2016 zxfonline@sina.com. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncSendMsg

func AsyncSendMsg(data interface{}, callback CallBackMsg) error

func DelSession

func DelSession(id int64)

func NewSession

func NewSession() int64

func RecMsg

func RecMsg(sId int64) interface{}

func SendMsg

func SendMsg(sessionid int64, data interface{}, callback CallBackMsg) 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() *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