socket

package
v0.0.0-...-f84f93e Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROTOLen uint32 = 4
	DataLen  uint32 = 4 //包信息数据长度占位长度
)
View Source
const (
	// 网络掉线事件
	OFFLINE = "offline"
)

Variables

View Source
var (
	VERSION    = "0.0.1"
	BUILD_TIME = ""
	RUN_TIME   = time.Now().Format("2006-01-02 15:04:05")
)
View Source
var HANDDLen uint32 = 9
View Source
var HeaderLen uint32 = 1 // 包头长度

Functions

func Close

func Close()

在线人数

func DecodeUint32

func DecodeUint32(data []byte) uint32

Big Endian

func EncodeUint32

func EncodeUint32(n uint32) []byte

Big Endian

func OnlineCount

func OnlineCount() uint32

在线人数

func Pack

func Pack(proto uint32, message []byte, count uint32) []byte

封包

func Regist

func Regist(s interface{}, f interface{})

func Server

func Server(addr string) (ln net.Listener)

func Unpack

func Unpack(buffer []byte, length uint32, readerChannel chan *Packet) uint32

解包

Types

type Connection

type Connection struct {
	ReadChan chan *Packet

	event.Dispatcher // 事件管理器
	// contains filtered or unexported fields
}

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) GetConnected

func (c *Connection) GetConnected() bool

func (*Connection) GetIPAddr

func (c *Connection) GetIPAddr() uint32

func (*Connection) GetLogin

func (c *Connection) GetLogin() bool

func (*Connection) GetUserid

func (c *Connection) GetUserid() string

func (*Connection) LoginTimeout

func (c *Connection) LoginTimeout()

func (*Connection) ReadPump

func (c *Connection) ReadPump()

func (*Connection) Reader

func (c *Connection) Reader(readChan chan *Packet)

func (*Connection) Send

func (c *Connection) Send(data interfacer.IProto)

func (*Connection) SetLogin

func (c *Connection) SetLogin()

func (*Connection) SetUserid

func (c *Connection) SetUserid(userid string)

func (*Connection) WritePump

func (c *Connection) WritePump()

type Packet

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

func (*Packet) GetContent

func (this *Packet) GetContent() []byte

func (*Packet) GetProto

func (this *Packet) GetProto() uint32

func (*Packet) SetContent

func (this *Packet) SetContent(content []byte)

func (*Packet) SetProto

func (this *Packet) SetProto(proto uint32)

Jump to

Keyboard shortcuts

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