Documentation ¶
Index ¶
- Constants
- Variables
- func EventName(event uint32) string
- func EventNameN(name string) uint32
- func InetAtoN(ip string) uint32
- func InetNtoA(i uint32) string
- func IsControl(v uint8) bool
- func IsEvent(v uint8) bool
- func IsEventID(v uint32) bool
- func PipeEvent(p mangos.Pipe) uint32
- func PutHeader(header []byte, src uint32, signalling uint8, dest uint32, key uint64) []byte
- func StringHeader(header []byte) string
- type Header
- func (h *Header) BalanceKey() uint64
- func (h *Header) Dest() uint32
- func (h *Header) Flag() uint16
- func (h *Header) HasHash() bool
- func (h *Header) HasRound() bool
- func (h *Header) HeaderLength() uint8
- func (h *Header) IsControl() bool
- func (h *Header) IsDhc() bool
- func (h *Header) IsEvent() bool
- func (h *Header) IsHeart() bool
- func (h *Header) IsRegisterEvent() bool
- func (h *Header) SetBalanceKey(v uint64)
- func (h *Header) SetDest(v uint32)
- func (h *Header) SetFlag(v uint16)
- func (h *Header) SetHeaderLength(v uint8)
- func (h *Header) SetSignalling(v uint8)
- func (h *Header) SetSignallingCommand(v uint8)
- func (h *Header) SetSignallingType(v uint8)
- func (h *Header) SetSrc(v uint32)
- func (h *Header) SetVersion(v uint8)
- func (h *Header) Signalling() uint8
- func (h *Header) SignallingCommand() uint8
- func (h *Header) SignallingType() uint8
- func (h *Header) Src() uint32
- func (h *Header) String() string
- func (h *Header) Version() uint8
- type Pipe
- type PipeEventHook
- type Protocol
- type Socket
Constants ¶
View Source
const ( DefaultFlag = 0x6562 // eb DefaultVersion = 0x1 DefaultHeaderLength = 12 DefaultEventHeaderLength = 20 MaxHeaderLength = 60 MaskVersion = 0xF0 MaskHeaderLength = 0x0F MaskEventID uint32 = 0x80000000 // 事件ID掩码 MaskInterIP uint32 = 0x7FFFFFFF // 内部IP掩码 )
View Source
const ( SignallingCommand uint8 = 0x0F // Command mask SignallingType uint8 = 0xF0 // Type Mask SignallingAssign uint8 = 0x00 // Assign flag SignallingEvent uint8 = 0x10 // Event flag SignallingControl uint8 = 0x20 // Control flag )
Signalling Format (UINT8):
7 6 5 4 3 2 1 0 * * * * * * * * │ │ │ │ │ │ └─┬─┘ │ │ └─────┬─────┘ Reserve │ │ └> Command - 0x00 ~ 0x0F │ └> Event - 0x10 └> Control - 0x20 0 0 0 0 -> Assign - 0x00
View Source
const ( SignallingHeart uint8 = 0x00 // Heart SignallingRegisterEvent uint8 = 0x01 // Register event SignallingDhc uint8 = 0x02 // Dynamic host configuration )
Control Command
View Source
const ( SignallingRandom uint8 = 0x00 // random SignallingHash uint8 = 0x01 // Hash SignallingRound uint8 = 0x02 // round SignallingEventHash = SignallingEvent | SignallingHash // Hash event command mask )
Event Command
View Source
const ( ProtoEventBus = 170 ProtoEvent = 171 )
View Source
const ( OptionHeartTime = "HEART_TIME" OptionReconnect = "RECONNECT" OptionTraceMessage = "TRACE_MESSAGE" )
View Source
const ( PipeEventRegistered = iota + mangos.PipeEventDetached + 1 PipeEventHeartBeat )
View Source
const (
ErrBadHeader = errors.ErrBadHeader
)
View Source
const (
PipeEbus = 0x65627573 | 0x80000000 // ebus
)
Variables ¶
Functions ¶
func EventNameN ¶
func StringHeader ¶
Types ¶
type Header ¶
type Header struct {
Data []byte
}
func (*Header) BalanceKey ¶ added in v0.2.0
func (*Header) HeaderLength ¶
func (*Header) IsRegisterEvent ¶
func (*Header) SetBalanceKey ¶ added in v0.2.0
func (*Header) SetHeaderLength ¶
func (*Header) SetSignalling ¶
func (*Header) SetSignallingCommand ¶ added in v0.2.0
func (*Header) SetSignallingType ¶
func (*Header) SetVersion ¶
func (*Header) Signalling ¶
func (*Header) SignallingCommand ¶ added in v0.2.0
func (*Header) SignallingType ¶
type Pipe ¶
type Pipe interface { // Event returns event id Event() uint32 // SetEvent is set event id SetEvent(uint32) // RemoteID is remote id RemoteID() uint32 // LocalAddr is local address LocalAddr() string // RemoteAddr is remote address RemoteAddr() string // Pipe is mangos pipe Pipe() mangos.Pipe // ID returns a unique 31-bit value associated with this. // The value is unique for a given socket, at a given time. ID() uint32 // Close does what you think. Close() error // Stop does with no reconnect Stop() // SendMsg sends a message. On success, it returns nil. This is a // blocking call. SendMsg(*protocol.Message) error // RecvMsg receives a message. It blocks until the message is // received. On error, the pipe is closed and nil is returned. RecvMsg() *protocol.Message // SetPrivate is used to set protocol private data. SetPrivate(interface{}) // GetPrivate returns the previously stored protocol private data. GetPrivate() interface{} }
type PipeEventHook ¶
type PipeEventHook func(mangos.PipeEvent, Pipe) interface{}
type Protocol ¶
type Protocol interface { protocol.Protocol SetPipeEventHook(PipeEventHook) }
type Socket ¶
type Socket interface { // Info returns information about the protocol (numbers and names) // and peer protocol. Info() mangos.ProtocolInfo // Close closes the open Socket. Further operations on the socket // will return ErrClosed. Close() error // Send puts the message on the outbound send queue. It blocks // until the message can be queued, or the send deadline expires. // If a queued message is later dropped for any reason, // there will be no notification back to the application. Send([]byte) error // Recv receives a complete message. The entire message is received. Recv() ([]byte, error) // SendMsg puts the message on the outbound send. It works like Send, // but allows the caller to supply message headers. AGAIN, the Socket // ASSUMES OWNERSHIP OF THE MESSAGE. SendMsg(*protocol.Message) error // RecvMsg receives a complete message, including the message header, // which is useful for protocols in raw mode. RecvMsg() (*protocol.Message, error) // Dial connects a remote endpoint to the Socket. The function // returns immediately, and an asynchronous goroutine is started to // establish and maintain the connection, reconnecting as needed. // If the address is invalid, then an error is returned. Dial(addr string) error DialOptions(addr string, options map[string]interface{}) error // NewDialer returns a Dialer object which can be used to get // access to the underlying configuration for dialing. NewDialer(addr string, options map[string]interface{}) (mangos.Dialer, error) // Listen connects a local endpoint to the Socket. Remote peers // may connect (e.g. with Dial) and will each be "connected" to // the Socket. The accepter logic is run in a separate goroutine. // The only error possible is if the address is invalid. Listen(addr string) error ListenOptions(addr string, options map[string]interface{}) error NewListener(addr string, options map[string]interface{}) (mangos.Listener, error) // GetOption is used to retrieve an option for a socket. GetOption(name string) (interface{}, error) // SetOption is used to set an option for a socket. SetOption(name string, value interface{}) error // OpenContext creates a new Context. If a protocol does not // support separate contexts, this will return an error. OpenContext() (mangos.Context, error) // SetPipeEventHook sets a PipeEventHook function to be called when a // Pipe is added or removed from this socket (connect/disconnect). SetPipeEventHook(PipeEventHook) }
func MakeSocket ¶
MakeSocket creates a Socket on top of a Protocol.
Click to show internal directories.
Click to hide internal directories.