network

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionInterval int64 = 30

ConnectionInterval Limit frequent connections to the same address

Functions

This section is empty.

Types

type Event

type Event struct {
	ID       int
	SignType string
	From     []byte
	To       []byte
	Time     int64
	Info     interface{}
	// contains filtered or unexported fields
}

Event event

func (*Event) GetMessage

func (c *Event) GetMessage() interface{}

GetMessage get message

func (*Event) GetPeerID

func (c *Event) GetPeerID() []byte

GetPeerID get peer id

func (*Event) GetSession

func (c *Event) GetSession() libp2p.Session

GetSession get session

func (*Event) Reply

func (c *Event) Reply(msg interface{}) error

Reply reply message

type Manager

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

Manager network manager

func New

func New() *Manager

New new network manager

func (*Manager) Close

func (m *Manager) Close()

Close close manager

func (*Manager) GetAddress

func (m *Manager) GetAddress() string

GetAddress get address

func (*Manager) Listen

func (m *Manager) Listen(address string) error

Listen listen, support multi Listen, address split with ','

func (*Manager) NewSession

func (m *Manager) NewSession(address string) (libp2p.Session, error)

NewSession new connection

func (*Manager) RegistPlugin

func (m *Manager) RegistPlugin(p libp2p.IPlugin)

RegistPlugin regist plugin

func (*Manager) SendInternalMsg

func (m *Manager) SendInternalMsg(msg libp2p.InterMsg)

SendInternalMsg send internal message

func (*Manager) SetConnPoolMgr

func (m *Manager) SetConnPoolMgr(p libp2p.ConnPoolMgr)

SetConnPoolMgr set manager of connection pool

func (*Manager) SetKeyMgr

func (m *Manager) SetKeyMgr(key libp2p.CryptoMgr)

SetKeyMgr set key manager of sign

type Session

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

Session session

func (*Session) Close

func (s *Session) Close()

Close close session

func (*Session) GetEnv

func (s *Session) GetEnv(key string) string

GetEnv get env

func (*Session) GetNetwork

func (s *Session) GetNetwork() libp2p.Network

GetNetwork get network

func (*Session) GetPeerAddr

func (s *Session) GetPeerAddr() libp2p.Addr

GetPeerAddr get remote address

func (*Session) GetSelfAddr

func (s *Session) GetSelfAddr() libp2p.Addr

GetSelfAddr get self address

func (*Session) Send

func (s *Session) Send(msg interface{}) error

Send send struct data,encode by gob

func (*Session) SetEnv

func (s *Session) SetEnv(key, value string)

SetEnv set env

Jump to

Keyboard shortcuts

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