Documentation
¶
Overview ¶
Package hub 负责把开发机与手机接起来,并在两者之间原样转发密文帧。
Index ¶
- Constants
- Variables
- func ChannelHex(id [ChannelIDLen]byte) string
- type ByteRecorder
- type Host
- type Hub
- func (h *Hub) AccountOnline(accountID string) int
- func (h *Hub) AttachDevice(hostID string, sink Sink) ([ChannelIDLen]byte, error)
- func (h *Hub) AttachDeviceLane(hostID, lane string, sink Sink) ([ChannelIDLen]byte, error)
- func (h *Hub) AttachHostLane(id string, generation uint64, lane string, sink Sink) (*Host, uint64, error)
- func (h *Hub) DetachDevice(host *Host, id [ChannelIDLen]byte)
- func (h *Hub) DetachHostLane(id, lane string, generation, attachID uint64)
- func (h *Hub) FromDevice(host *Host, id [ChannelIDLen]byte, frame []byte) error
- func (h *Hub) FromHost(host *Host, frame []byte) error
- func (h *Hub) FromHostLane(host *Host, lane string, frame []byte) error
- func (h *Hub) HostCount() int
- func (h *Hub) NodeID() string
- func (h *Hub) Online(id string) (*Host, bool)
- func (h *Hub) RegisterHost(id, name, accountID, bundleID string, version byte, maxPeers int, sink Sink) *Host
- func (h *Hub) SetByteRecorder(fn ByteRecorder)
- func (h *Hub) SetNodeID(nodeID string)
- func (h *Hub) UnregisterHost(host *Host)
- type PushSender
- type Sink
Constants ¶
const ChannelIDLen = protocol.ChannelIDLen
Variables ¶
Functions ¶
func ChannelHex ¶
func ChannelHex(id [ChannelIDLen]byte) string
Types ¶
type ByteRecorder ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func New ¶
func New(push PushSender) *Hub
func (*Hub) AccountOnline ¶
func (*Hub) AttachDevice ¶
func (*Hub) AttachDeviceLane ¶
func (*Hub) AttachHostLane ¶
func (h *Hub) AttachHostLane(id string, generation uint64, lane string, sink Sink) (*Host, uint64, error)
AttachHostLane binds an authenticated extra socket to an existing registration generation. It never replaces the primary registration. The returned attachID must be passed to DetachHostLane so a deferred cleanup from an older socket cannot close its replacement.
func (*Hub) DetachDevice ¶
func (h *Hub) DetachDevice(host *Host, id [ChannelIDLen]byte)
func (*Hub) DetachHostLane ¶
DetachHostLane drops an extra lane without touching the primary registration. attachID must match the current lane owner; stale deferred cleanups are no-ops.
func (*Hub) FromDevice ¶
func (*Hub) RegisterHost ¶
func (*Hub) SetByteRecorder ¶
func (h *Hub) SetByteRecorder(fn ByteRecorder)