WebsocketDealer

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

@Title WebsocketDealer.go @Description 实现websocket低成本call 需要客户端配合 @Author Dorbmon

Index

Constants

View Source
const (
	ModuleName    = "WebsocketDealer"
	ModuleVersion = 0.2
)

Variables

View Source
var Once sync.Once

Functions

func InitWebsocketDealer added in v0.0.4

func InitWebsocketDealer()

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

type Replier added in v0.0.4

type Replier struct {
	// contains filtered or unexported fields
}

func (*Replier) Call added in v0.0.4

func (z *Replier) Call(functionName string, args ...interface{}) (interface{}, error)

func (*Replier) Return added in v0.0.4

func (z *Replier) Return(data interface{}) error

type StandardCall

type StandardCall struct {
	Function string        `json:"function"`
	Argument []interface{} `json:"argument"`
	Id       uint64        `json:"id"`
	IsReply  bool          `json:"reply"` //只是保留,客户端不需要实现 若为Reply时,需要设置为true
}

type StandardReply added in v0.0.4

type StandardReply struct {
	Id   uint64      `json:"id"`
	Data interface{} `json:"data"`
}

type WebsocketDealFunction

type WebsocketDealFunction func(replier *Replier, arguments []interface{})

type WebsocketDealer

type WebsocketDealer struct {
	OriginCheck func(ctx *RWeb.Context) bool
	// contains filtered or unexported fields
}

func New

func New() (r WebsocketDealer)

func (*WebsocketDealer) BindFunction

func (z *WebsocketDealer) BindFunction(FunctionName string, Function WebsocketDealFunction) error

func (*WebsocketDealer) BindReplyId added in v0.0.4

func (z *WebsocketDealer) BindReplyId(id uint64, c chan StandardReply)

func (*WebsocketDealer) Handler

func (z *WebsocketDealer) Handler(context *RWeb.Context)

* 使用此函数作为引擎的绑定函数

func (*WebsocketDealer) RemoveBindReplyId added in v0.0.4

func (z *WebsocketDealer) RemoveBindReplyId(id uint64)

type WebsocketResponse added in v0.0.4

type WebsocketResponse struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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