network

package
v0.0.0-...-917d9ad Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalAddress = "nonhost"
)

Variables

View Source
var File_client_id_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AcceptMessage

type AcceptMessage struct {
}

type CIDKEY

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

func Key

func Key(cid *ClientID) CIDKEY

type Client

type Client interface {
	Accept(Context)
	Ping(Context)
	Recvice(Context)
	Closed(Context)
}

type ClientHandler

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

func (*ClientHandler) Close

func (c *ClientHandler) Close()

func (*ClientHandler) PostMessage

func (c *ClientHandler) PostMessage(b []byte) error

func (*ClientHandler) PostToMessage

func (c *ClientHandler) PostToMessage(b []byte, target net.Addr) error

type ClientID

type ClientID struct {
	Address string `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"` // 地址
	Id      string `protobuf:"bytes,2,opt,name=Id,proto3" json:"Id,omitempty"`           // 唯一标记
	// contains filtered or unexported fields
}

func NewClientID

func NewClientID(address, id string) *ClientID

func (*ClientID) Descriptor deprecated

func (*ClientID) Descriptor() ([]byte, []int)

Deprecated: Use ClientID.ProtoReflect.Descriptor instead.

func (*ClientID) Equal

func (cid *ClientID) Equal(other *ClientID) bool

func (*ClientID) GetAddress

func (x *ClientID) GetAddress() string

func (*ClientID) GetId

func (x *ClientID) GetId() string

func (*ClientID) IsVaild

func (cid *ClientID) IsVaild() bool

func (*ClientID) PostUserMessage

func (cid *ClientID) PostUserMessage(message []byte) error

func (*ClientID) PostUserToMessage

func (cid *ClientID) PostUserToMessage(message []byte, target net.Addr) error

func (*ClientID) ProtoMessage

func (*ClientID) ProtoMessage()

func (*ClientID) ProtoReflect

func (x *ClientID) ProtoReflect() protoreflect.Message

func (*ClientID) Reset

func (x *ClientID) Reset()

func (*ClientID) String

func (x *ClientID) String() string

func (*ClientID) ToString

func (cid *ClientID) ToString() string

func (*ClientID) UserClose

func (cid *ClientID) UserClose() error

type ClientIDSet

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

func (*ClientIDSet) Clear

func (cis *ClientIDSet) Clear()

Clear removes all the elements in the set.

func (*ClientIDSet) Contains

func (cis *ClientIDSet) Contains(v *ClientID) bool

func (*ClientIDSet) Empty

func (cis *ClientIDSet) Empty() bool

Empty reports whether the set is empty.

func (*ClientIDSet) Erase

func (cis *ClientIDSet) Erase(v *ClientID) bool

func (*ClientIDSet) ForEach

func (cis *ClientIDSet) ForEach(f func(i int, cid *ClientID))

ForEach invokes f for every element of the set.

func (*ClientIDSet) Get

func (cis *ClientIDSet) Get(index int) *ClientID

func (*ClientIDSet) Len

func (cis *ClientIDSet) Len() int

func (*ClientIDSet) Push

func (cis *ClientIDSet) Push(v *ClientID)

func (*ClientIDSet) Values

func (cis *ClientIDSet) Values() []*ClientID

Values returns all the elements of the set as a slice.

type ClosedMessage

type ClosedMessage struct {
}

type Config

type Config struct {
	Producer   ProducerWidthClientSystem
	Kleepalive int32  //网络超时(单位毫秒)
	VAddr      string // 虚地址标记
}

func Configure

func Configure(options ...ConfigOption) *Config

type ConfigOption

type ConfigOption func(config *Config)

ConfigOption 是一个配置Network系统的函数

func WithKleepalive

func WithKleepalive(timeout int32) ConfigOption

WithKleepalive 保活时间

func WithProducer

func WithProducer(producer ProducerWidthClientSystem) ConfigOption

func WithVAddr

func WithVAddr(vaddr string) ConfigOption

type Context

type Context interface {
	// Client
	Client() Client
	// Self clientId
	Self() *ClientID
	// NetworkSystem System object
	NetworkSystem() *NetworkSystem
	// Message 返回当前数据
	Message() []byte
	MessageFrom() net.Addr
	PostMessage(*ClientID, []byte) error
	PostToMessage(*ClientID, []byte, net.Addr) error
	// Close 关闭当前连接
	Close(*ClientID)
}

type HandleRegistryValue

type HandleRegistryValue struct {
	Address string
	// contains filtered or unexported fields
}

func NewHandlerRegistry

func NewHandlerRegistry(system *NetworkSystem, vaddr string) *HandleRegistryValue

func (*HandleRegistryValue) Get

func (hr *HandleRegistryValue) Get(cid *ClientID) (Handler, bool)

func (*HandleRegistryValue) GetLocal

func (hr *HandleRegistryValue) GetLocal(id string) (Handler, bool)

func (*HandleRegistryValue) NextId

func (hr *HandleRegistryValue) NextId() string

func (*HandleRegistryValue) Push

func (hr *HandleRegistryValue) Push(handler Handler, id string) (*ClientID, bool)

func (*HandleRegistryValue) Remove

func (hr *HandleRegistryValue) Remove(cid *ClientID)

type Handler

type Handler interface {
	PostMessage([]byte) error
	PostToMessage([]byte, net.Addr) error
	Close()
	// contains filtered or unexported methods
}

type MessageInvoker

type MessageInvoker interface {
	// contains filtered or unexported methods
}

type NetworkModule

type NetworkModule interface {
	Open(string) error
	Network() string
	Stop()
}

type NetworkSystem

type NetworkSystem struct {
	Config *Config
	ID     string
	// contains filtered or unexported fields
}

NetworkSystem 网络系统

func NewTCPServerNetworkSystem

func NewTCPServerNetworkSystem(options ...ConfigOption) *NetworkSystem

func NewTCPServerNetworkSystemConfig

func NewTCPServerNetworkSystemConfig(config *Config) *NetworkSystem

func NewTCPSyncServerNetworkSystem

func NewTCPSyncServerNetworkSystem(options ...ConfigOption) *NetworkSystem

func NewTCPSyncServerNetworkSystemConfig

func NewTCPSyncServerNetworkSystemConfig(config *Config) *NetworkSystem

func NewUDPNetworkSystem

func NewUDPNetworkSystem(options ...ConfigOption) *NetworkSystem

func NewUDPNetworkSystemConfig

func NewUDPNetworkSystemConfig(config *Config) *NetworkSystem

func (*NetworkSystem) Address

func (ns *NetworkSystem) Address() string

func (*NetworkSystem) NewClientID

func (ns *NetworkSystem) NewClientID(id string) *ClientID

func (*NetworkSystem) Open

func (ns *NetworkSystem) Open(addr string) error

func (*NetworkSystem) Shutdown

func (ns *NetworkSystem) Shutdown()

type PingMessage

type PingMessage struct {
}

type ProducerWidthClientSystem

type ProducerWidthClientSystem func(*NetworkSystem) Client

type RecviceMessage

type RecviceMessage struct {
	Data []byte
	Addr net.Addr
}

Jump to

Keyboard shortcuts

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