akWebNet

package
Version: v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MID_login          = 1  //上线 (获取自己的数据)
	MID_logout         = 2  //离线
	MID_move           = 3  //移动
	MID_Bump           = 4  //撞击
	MID_HeartBeat      = 5  //心跳
	MID_StarBorn       = 6  //星星出生
	MID_GM             = 7  //gm
	MID_Online4Other   = 8  //上线获取别人数据显示或者广播自己数据给别人显示
	MID_Register       = 9  //注册
	MID_SyncPos        = 10 //同步位置
	MID_MonsterInfo    = 11 //同步moster信息
	MID_LogicFrameSync = 12 //逻辑帧同步其他客户端moster信息
)

message ID

View Source
const (
	MsgSendType_P2P       = 1 //点对点 直接发送
	MsgSendType_BroadCast = 2 //广播
)

Variables

View Source
var (
	GwebSessionMgr *wsClientSession
)

Functions

func BinaryMessageFunc added in v0.0.2

func BinaryMessageFunc(sess *WebSession, msg *wsMessage)

func BroadCastMsgExceptID added in v0.0.2

func BroadCastMsgExceptID(msgid int, msgparams []uint32)

func BroadCastMsgExceptSession added in v0.0.2

func BroadCastMsgExceptSession(selfsess *WebSession, bMsg2Me bool, msgid int, msgparams []uint32)

广播消息

@param 1: 自身会话
@param 2:是否不给自己广播
@param 3:消息ID
@param 4:消息参数

func CloseMessageFunc added in v0.0.2

func CloseMessageFunc(sess *WebSession, msg *wsMessage)

func GetMessageHandler added in v0.0.2

func GetMessageHandler(id int) receiveMsgProc

func HeartBeat added in v0.0.2

func HeartBeat(sess *WebSession, data []uint32) (error, bool)

func MsgRegister added in v0.0.2

func MsgRegister(id int, cb WsCallback)

func PingMessageFunc added in v0.0.2

func PingMessageFunc(sess *WebSession, msg *wsMessage)

func PongMessageFunc added in v0.0.2

func PongMessageFunc(sess *WebSession, msg *wsMessage)

func SendMsg added in v0.0.2

func SendMsg(sess *WebSession, msgid int, msgparams []uint32)

func TextMessageFunc added in v0.0.2

func TextMessageFunc(sess *WebSession, msg *wsMessage)

Types

type WebSession added in v0.0.2

type WebSession struct {
	RemoteAddr string

	IdCh *uint32
	// contains filtered or unexported fields
}

func NewWebSession added in v0.0.2

func NewWebSession(conn *websocket.Conn, off chan *WebSession) *WebSession

func (*WebSession) GetId added in v0.0.2

func (this *WebSession) GetId() uint32

func (*WebSession) Handle added in v0.0.2

func (this *WebSession) Handle()

func (*WebSession) SetId added in v0.0.2

func (this *WebSession) SetId(id uint32)

func (*WebSession) Write added in v0.0.2

func (this *WebSession) Write(msgtype int, data []byte)

type WebSocketSvr added in v0.0.2

type WebSocketSvr struct {
	Addr string
	// contains filtered or unexported fields
}

func NewWebsocketSvr added in v0.0.2

func NewWebsocketSvr(addr string) *WebSocketSvr

func (*WebSocketSvr) Run added in v0.0.2

func (this *WebSocketSvr) Run()

type WsCallback added in v0.0.2

type WsCallback func(ws *WebSession, data []uint32) (error, bool)

func GetGameLogicProcMsg added in v0.0.2

func GetGameLogicProcMsg(id int) WsCallback

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL