common

package
Version: v0.0.0-...-2e119b9 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ConstHeader         = "{28285252_hcaiyue_top_15159898}"
	ConstHeaderLength   = len(ConstHeader)
	ConstSaveDataLength = 8
	ConstFooter         = "{137621_woyaoyigebaojieshula_159687}"
	ConstFooterLength   = len(ConstFooter)
)

Variables

View Source
var ServiceName = GetServiceName(os.Args[0])

Functions

func BytesToInt

func BytesToInt(b []byte) int

字节转换成整形

func Call

func Call(m map[string]interface{}, name string, params ...interface{}) (result []reflect.Value, err error)

func FileIsExist

func FileIsExist(FileName string) bool

func GetRunDir

func GetRunDir() string

func GetServiceName

func GetServiceName(str string) string

func IntToBytes

func IntToBytes(n int) []byte

整形转换成字节

func LogToFile

func LogToFile()

func Packet

func Packet(message []byte) []byte

封包

func Unpack

func Unpack(buffer []byte, reader *[]byte) []byte

解包

Types

type Client

type Client struct {
	Conn      net.Conn
	Msgreturn map[string]chan Msg
	Methods   map[string]interface{}
	WriteChan chan []byte
}

func InitClient

func InitClient() *Client

func (*Client) ConnWrite

func (this *Client) ConnWrite(data Msg)

func (*Client) ConnWriteReturn

func (this *Client) ConnWriteReturn(data Msg) (msg Msg)

func (*Client) HeartBeat

func (this *Client) HeartBeat()

func (*Client) InitMethods

func (this *Client) InitMethods(m map[string]interface{})

func (*Client) MsgReturn

func (this *Client) MsgReturn(data Msg)

func (*Client) SericeInit

func (this *Client) SericeInit()

func (*Client) ServiceHandle

func (this *Client) ServiceHandle(conn net.Conn)

func (*Client) ServiceProcess

func (this *Client) ServiceProcess(str []byte)

func (*Client) ServiceWriteHandle

func (this *Client) ServiceWriteHandle(conn net.Conn)

type ConfigModel

type ConfigModel struct {
	Services []ServicesModel   `json:"services"`
	Routing  map[string]string `json:"routing"`
}

type ConnInsID

type ConnInsID struct {
	ID int64
	// contains filtered or unexported fields
}
var CID ConnInsID

func (*ConnInsID) Get

func (self *ConnInsID) Get() int64

type Msg

type Msg struct {
	Method string `json:"method"`
	Data   string `json:"data"`
	To     string `json:"to"`
	ID     string `json:"id"`
}

type Resp

type Resp struct {
	Data   string `json:"data"`
	Status int    `json:"status"`
	ID     string `json:"id"`
}

type ServicesModel

type ServicesModel struct {
	Name string `json:"name"`
	Run  int    `json:"run"`
}

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