mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Listen-Accept-Read-Write pattern now works, amazingly
This commit is contained in:
parent
27b78b925d
commit
aac88adbed
4 changed files with 91 additions and 17 deletions
|
@ -254,6 +254,20 @@ func (c *Core) Stop() {
|
|||
c.admin.close()
|
||||
}
|
||||
|
||||
// ListenConn returns a listener for Yggdrasil session connections.
|
||||
func (c *Core) ListenConn() (*Listener, error) {
|
||||
c.sessions.listenerMutex.Lock()
|
||||
defer c.sessions.listenerMutex.Unlock()
|
||||
if c.sessions.listener != nil {
|
||||
return nil, errors.New("a listener already exists")
|
||||
}
|
||||
c.sessions.listener = &Listener{
|
||||
conn: make(chan *Conn),
|
||||
close: make(chan interface{}),
|
||||
}
|
||||
return c.sessions.listener, nil
|
||||
}
|
||||
|
||||
// Dial opens a session to the given node. The first paramter should be "nodeid"
|
||||
// and the second parameter should contain a hexadecimal representation of the
|
||||
// target node ID.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue