network

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

*

  • ______ __
  • /\__ _\ /\ \
  • \/_/\ \/ ___ __\ \ \ __ ___ ___ __
  • \ \ \ / ___\ / __ \ \ \ __ / __ \ / _ \ / ___\ / __ \
  • \_\ \__/\ \__//\ __/\ \ \_\ \/\ \_\ \_/\ \/\ \/\ \__//\ __/
  • /\_____\ \____\ \____\\ \____/\ \__/ \_\ \_\ \_\ \____\ \____\
  • \/_____/\/____/\/____/ \/___/ \/__/\/_/\/_/\/_/\/____/\/____/ * *
  • @寒冰
  • www.icezzz.cn
  • hanbin020706@163.com

*

  • ______ __
  • /\__ _\ /\ \
  • \/_/\ \/ ___ __\ \ \ __ ___ ___ __
  • \ \ \ / ___\ / __ \ \ \ __ / __ \ / _ \ / ___\ / __ \
  • \_\ \__/\ \__//\ __/\ \ \_\ \/\ \_\ \_/\ \/\ \/\ \__//\ __/
  • /\_____\ \____\ \____\\ \____/\ \__/ \_\ \_\ \_\ \____\ \____\
  • \/_____/\/____/\/____/ \/___/ \/__/\/_/\/_/\/_/\/____/\/____/ * *
  • @寒冰
  • www.icezzz.cn
  • hanbin020706@163.com

Index

Constants

View Source
const (
	DataSliceLength = 1400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

func (*Connection) EnCoder

func (u *Connection) EnCoder(message []byte, messageType uint16) [][]byte

func (*Connection) GetName

func (u *Connection) GetName() string

func (*Connection) Receive

func (u *Connection) Receive() error

接收从用户的连接读取下一条消息。 它会阻塞直到收到完整的消息。

func (*Connection) Write added in v0.1.17

func (u *Connection) Write(md *MessageData) error

type ConnectionGroup

type ConnectionGroup struct {
	Hanlder *Handler
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(pool *gopool.Pool) *ConnectionGroup

func (*ConnectionGroup) Register

func (c *ConnectionGroup) Register(name string, conn net.Conn) *Connection

Register registers new connection as a User.

func (*ConnectionGroup) Remove

func (c *ConnectionGroup) Remove(user *Connection)

Remove removes user from chat.

func (*ConnectionGroup) Rename

func (c *ConnectionGroup) Rename(user *Connection, name string) (prev string, ok bool)

Rename renames user.

type Handler

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

func (*Handler) AddHandler

func (h *Handler) AddHandler(messageType uint16, fun RecvHandler)

func (*Handler) Execute

func (h *Handler) Execute(data *MessageData) *MessageData

func (*Handler) Init

func (h *Handler) Init()

type MessageData

type MessageData struct {
	MessageType uint16
	Message     []byte
}

type NetManager

type NetManager struct {
	Pool   *gopool.Pool
	Poller netpoll.Poller
	Group  *ConnectionGroup
}

func NewNetManager

func NewNetManager() *NetManager

type RecvHandler

type RecvHandler func(message *MessageData) *MessageData

Jump to

Keyboard shortcuts

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