dream

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

README

dream

介绍

golang 工具类

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const LOG_DEF int = 0
View Source
const LOG_HTTP = -419
View Source
const LOG_KERL int = -417
View Source
const LONG_TIME_FUNC = time.Duration(100) * time.Millisecond
View Source
const PACKAGE_FLAG_CONFIG = "@VIOXYCFG:" //规定设置数据格式  headerxyid,ip,dataformat-
View Source
const XY_CONFIG = 30003
View Source
const XY_REGISTER = 30001
View Source
const XY_REGISTER_RSP = 30002

Variables

This section is empty.

Functions

func AppName

func AppName() string

func Assert

func Assert(cond bool, format string, a ...interface{})

func AssertImposible

func AssertImposible(cond bool, format string, a ...interface{})

func CrashSnap

func CrashSnap(err interface{})

func GetCurrentPath

func GetCurrentPath() string

func GetWorkPath

func GetWorkPath() string

func GoID

func GoID() uint64

func IsFileIsExist

func IsFileIsExist(filename string) bool

func IsFullPath

func IsFullPath(path string) bool

func JsonSubObjString

func JsonSubObjString(s, key string) string

func LoadJson

func LoadJson(file string) (*JSONRead, JSONS)

func Log

func Log(a ...interface{})

func LogAdd

func LogAdd(id int, file string)

func LogShutdown

func LogShutdown()

func LogStartup

func LogStartup(config string)

func Logf

func Logf(f string, a ...interface{})

func Logfi

func Logfi(id int, f string, a ...interface{})

func Logi

func Logi(id int, a ...interface{})

func NewJSON

func NewJSON() map[string]interface{}

func PathCheckEndChar

func PathCheckEndChar(path string, add bool) (string, bool)

func SendPackAndRecv

func SendPackAndRecv(sock net.Conn, headertemp []byte, pack []byte) ([]byte, error)

func SetAppName

func SetAppName(n string)

func SetWorkPath

func SetWorkPath(s string)

Types

type ARACrpt

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

func (*ARACrpt) GetKey

func (ara *ARACrpt) GetKey() (uint32, uint32, uint32)

func (*ARACrpt) SetKey

func (ara *ARACrpt) SetKey(key1 uint32, key2 uint32, key3 uint32)

func (*ARACrpt) TransformChar

func (ara *ARACrpt) TransformChar(cTarget *byte)

func (*ARACrpt) TransformString

func (ara *ARACrpt) TransformString(csTarget *[]byte, cbsize uint32)

type AutoConnFunc

type AutoConnFunc func(data []byte, xy XY)

func (AutoConnFunc) OnPackage

func (f AutoConnFunc) OnPackage(data []byte, xy XY)

type ClientMeta

type ClientMeta struct {
	VerCode  int32  //客户端版本
	AppID    string //客户端APPKEY
	DeviceID string ////客户端设备特征码
}

FishClientMeta 客户端信息

type EVENT_SRC_ID

type EVENT_SRC_ID string

type HttpFunc

type HttpFunc func(r IRequest, w IResponse)

func (HttpFunc) OnHttpRequest

func (f HttpFunc) OnHttpRequest(r IRequest, w IResponse)

type HttpMux

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

func NewHttpMux

func NewHttpMux() *HttpMux

func (*HttpMux) Handle

func (p *HttpMux) Handle(pattern string, handler IHttpHandler)

func (*HttpMux) HandleFunc

func (p *HttpMux) HandleFunc(pattern string, handler func(IRequest, IResponse))

type IAutoConnHandler

type IAutoConnHandler interface {
	OnPackage(data []byte, xy XY)
}

type IAutoConnInterface

type IAutoConnInterface interface {
	OnReady(id int)
	OnPackage(data []byte, xy XY)
	OnClose()
}

type IAutoConnInterfacePre

type IAutoConnInterfacePre interface {
	OnReady(id int, ctrl IQueueItemCtrl)
	OnPackage(data []byte, xy XY, ctrl IQueueItemCtrl)
	OnClose(ctrl IQueueItemCtrl)
}

type IAutoConnInterfaceWithId

type IAutoConnInterfaceWithId interface {
	OnAutoConnReady(iid EVENT_SRC_ID, id int)
	OnAutoConnPackage(iid EVENT_SRC_ID, data []byte, xy XY)
	OnAutoConnClose(iid EVENT_SRC_ID)
}

type IAutoConnect

type IAutoConnect interface {
	IRun
	SendXY(xy XY, pack []byte) int
	IStop
}

func AutoConnect

func AutoConnect(n string, addrs string, auth string, svrType int, serviceid int, cbAutoConn IAutoConnInterface) IAutoConnect

type IClient

type IClient interface {
	Ip() string
	SetSilent()                                     //设置成静默,将永远不能再接收数据
	BreakConnect()                                  //中断连接
	SetUserData(k string, d interface{})            //设置数据,需要自行处理数据安全问题
	UserData(k string, def interface{}) interface{} //得到数据,需要自行处理数据安全问题
	UserDataNum(k string, def int64) int64          //得到数据,需要自行处理数据安全问题
	UserDataSss(k string, def string) string        //得到数据,需要自行处理数据安全问题
	CloseCause() int                                //关闭原因
	SendXY(xy XY, pack []byte) int
	SendPackage(pack []byte) int
}

type IClientInterface

type IClientInterface interface {
	OnClientPackage(c IClient, data []byte, xy XY)
	OnClientClose(c IClient)
}

type IClientInterfacePre

type IClientInterfacePre interface {
	OnClientPackage(c IClient, data []byte, xy XY, ctrl IQueueItemCtrl)
	OnClientClose(c IClient, ctrl IQueueItemCtrl)
}

type IClientInterfaceWithId

type IClientInterfaceWithId interface {
	OnClientPackage(iid EVENT_SRC_ID, c IClient, data []byte, xy XY)
	OnClientClose(iid EVENT_SRC_ID, c IClient)
}

type IDef

type IDef interface {
	SetDefInt(i int64) int64
	SetDefFloat(i float64) float64
	SetDefString(i string) string
	SetDefBool(i bool) bool
}

type IHttp

type IHttp interface {
	Get(url string) string
}

type IHttpHandler

type IHttpHandler interface {
	OnHttpRequest(r IRequest, w IResponse)
}

type IHttpInterface

type IHttpInterface interface {
	OnHttpRequest(r IRequest, file string, w IResponse)
}

type IHttpServer

type IHttpServer interface {
	IRun
	IStop
}

func ServeHttp

func ServeHttp(addr string, handler *HttpMux) IHttpServer

func ServeHttpAll

func ServeHttpAll(addr string, handler *HttpMux, cbConn INewConnInterface, cbIf IClientInterface, cbReg IRegisterInterface) IHttpServer

type INI

type INI struct {
	INIT
	// contains filtered or unexported fields
}

func LoadIni

func LoadIni(file string) (*INI, string)

func (INI) Int

func (p INI) Int(s, k string) int

func (INI) Is

func (p INI) Is(s, k string) bool

func (INI) Sec

func (p INI) Sec(s string) map[string]string

func (*INI) SetDefBool

func (p *INI) SetDefBool(i bool) bool

func (*INI) SetDefFloat

func (p *INI) SetDefFloat(i float64) float64

func (*INI) SetDefInt

func (p *INI) SetDefInt(i int64) int64

func (*INI) SetDefString

func (p *INI) SetDefString(i string) string

func (INI) Str

func (p INI) Str(s, k string) string

type INIT

type INIT = map[string]map[string]string

type INewConnInterface

type INewConnInterface interface {
	OnNewClientConnect(c IClient)
}

type IPool

type IPool interface {
	Get() interface{}
	Put(a interface{})
}

func NewHttpPool

func NewHttpPool(c interface{}, max uint32) IPool

func NewPool

func NewPool(fnew func(c interface{}) interface{}, c interface{}, max uint32) IPool

func NewSocketPool

func NewSocketPool(c string) IPool

type IQueueItemCtrl

type IQueueItemCtrl interface {
	Drop()
}

type IRegisterInterface

type IRegisterInterface interface {
	OnClientRegister(c IClient, id int32, processId int32, tpc int, auth string) bool
}

type IRequest

type IRequest = *http.Request

type IRequestComm

type IRequestComm = *ClientMeta

type IRequestData

type IRequestData []byte //= *json.Decoder

type IRequestData = *JSONRead

func (IRequestData) Decode

func (p IRequestData) Decode(v interface{}) error

Decode 客户端请求数据

type IResponse

type IResponse interface {
	http.ResponseWriter
	WriteJson(map[string]interface{}) (int, error)
	WriteFmt(a ...interface{}) (int, error)
	WriteJsonArr(a ...map[string]interface{}) (int, error)
}

type IRun

type IRun interface {
	Run(wg *sync.WaitGroup)
}

type IRunCtrl1

type IRunCtrl1 interface {
	IRun
	RunFunc(f func())
	IStop
}

func NewAsyncMultiRun

func NewAsyncMultiRun(n string, cnt uint32) IRunCtrl1

type IRunCtrl2

type IRunCtrl2 interface {
	IRunCtrl1
	SetupAutoConnInterface(iid EVENT_SRC_ID, prevIf IAutoConnInterfacePre) IAutoConnInterface
	SetupClientInterface(iid EVENT_SRC_ID, prevIf IClientInterfacePre) IClientInterface
}

func NewQueueRun

func NewQueueRun(n string, spanMs uint32, cbTick ITick, cbClientIf IClientInterfaceWithId, cbAutoConn IAutoConnInterfaceWithId) IRunCtrl2

type IServer

type IServer interface {
	IRun
	IStop
}

func ServeStartup

func ServeStartup(addr string,
	cbConn INewConnInterface,
	cbIf IClientInterface) IServer

func ServeStartupAll

func ServeStartupAll(addr string, cbConn INewConnInterface, cbIf IClientInterface, cbCheck IRegisterInterface) IServer

type ISocket

type ISocket interface {
	SendPackage(xy XY, pack []byte) error
	ReadPackage(rxy ...XY) (XY, []byte, error)
	Request(xy XY, pack []byte, rxy ...XY) (XY, []byte, error)

	JSONSendPackage(xy XY, json map[string]interface{}) error
	JSONReadPackage(rxy ...XY) (XY, map[string]interface{}, error)
	JSONRequest(xy XY, json map[string]interface{}, rxy ...XY) (XY, map[string]interface{}, error)
}

ISocket 无状态连接 注:同步的

type IStop

type IStop interface {
	Stop()
}

type ITick

type ITick interface {
	OnTick()
}

type JSONRead

type JSONRead struct {
	JSONT
	// contains filtered or unexported fields
}

func NewJSONRead

func NewJSONRead(j ...map[string]interface{}) *JSONRead

func (*JSONRead) Num

func (p *JSONRead) Num(s string, x ...interface{}) int64

Num 得到一个数字

func (*JSONRead) NumF64

func (p *JSONRead) NumF64(s string, x ...interface{}) float64

func (*JSONRead) SetDefBool

func (p *JSONRead) SetDefBool(i bool) bool

func (*JSONRead) SetDefFloat

func (p *JSONRead) SetDefFloat(i float64) float64

func (*JSONRead) SetDefInt

func (p *JSONRead) SetDefInt(i int64) int64

func (*JSONRead) SetDefString

func (p *JSONRead) SetDefString(i string) string

func (*JSONRead) Size

func (p *JSONRead) Size(s string, x ...interface{}) uint64

Size 得到数组元素的长度

func (*JSONRead) Sss

func (p *JSONRead) Sss(s string, x ...interface{}) string

Str 得到一个字符串

type JSONS

type JSONS string

func (JSONS) S

func (p JSONS) S(k string) JSONS

type JSONT

type JSONT = map[string]interface{}

type ServiceConfig

type ServiceConfig struct {
}

func (*ServiceConfig) AddClientHander

func (p *ServiceConfig) AddClientHander(cmd int16)

func (*ServiceConfig) AddHander

func (p *ServiceConfig) AddHander(id int)

func (*ServiceConfig) AddHttpHander

func (p *ServiceConfig) AddHttpHander(file string)

type TickFunc

type TickFunc func()

func (TickFunc) OnTick

func (f TickFunc) OnTick()

type XY

type XY int16

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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