Documentation
¶
Overview ¶
Package p2pc extends udpc to provide P2P functionality
Index ¶
- Constants
- type Config
- type Connection
- type Manager
- func (m *Manager) CloseAll()
- func (m *Manager) CloseConnection(cid string, reason string)
- func (m *Manager) ConnectById(peerId string, mode p2p.ConnectionMode) (conn *Connection, err error)
- func (m *Manager) ConnectByTag(tag string, mode p2p.ConnectionMode) (conn *Connection, err error)
- func (m *Manager) SetStreamHandler(handler udp.StreamHandler)
- type NewConnectionHandler
Constants ¶
View Source
const ( P2P_CONNECT_TRIES = 3 P2P_RECONNECT_TRIES = 3 )
View Source
const ( RELAY_CONNECT_TRIES = 3 RELAY_RECONNECT_TRIES = 4 RELAY_PEER_AWAIT_TIMEOUT = time.Second * 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Relay Server Address // Providing an address (non-nil) will ensure that all relay connections from this client // will use the server with this address RelayAddr *net.UDPAddr }
P2P Client Manager
type Connection ¶
type Connection struct { // Client ID ClientId string // Exit Channel Exit chan bool // Closed Status Closed bool // contains filtered or unexported fields }
P2P Client Connection
func (*Connection) Close ¶
func (c *Connection) Close(reason string)
func (*Connection) OpenStream ¶
Open Stream to Peer
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
P2P Client Manager
func New ¶
func New( log *logrus.Logger, config Config, client *udpc.Client, connectionHandler NewConnectionHandler, ) (m *Manager, err error)
Create new Manager
func (*Manager) CloseConnection ¶
Close Connection
func (*Manager) ConnectById ¶
func (m *Manager) ConnectById(peerId string, mode p2p.ConnectionMode) (conn *Connection, err error)
Connect to Client by ID
func (*Manager) ConnectByTag ¶
func (m *Manager) ConnectByTag(tag string, mode p2p.ConnectionMode) (conn *Connection, err error)
Connect to Client by Tag
func (*Manager) SetStreamHandler ¶
func (m *Manager) SetStreamHandler(handler udp.StreamHandler)
Set New Stream Handler
Source Files
¶
Click to show internal directories.
Click to hide internal directories.