forked from cwtch.im/cwtch
1
0
Fork 0

Merge pull request 'Split Peer and Server Connection Launching' (#326) from gating into master

Reviewed-on: cwtch.im/cwtch#326
This commit is contained in:
Dan Ballard 2020-10-29 15:31:08 -07:00
commit 8b176327a7
2 changed files with 15 additions and 7 deletions

View File

@ -93,6 +93,7 @@ type CwtchPeer interface {
Listen()
StartPeersConnections()
StartServerConnections()
Shutdown()
}
@ -480,13 +481,20 @@ func (cp *cwtchPeer) Listen() {
cp.eventBus.Publish(event.NewEvent(event.ProtocolEngineStartListen, map[event.Field]string{event.Onion: cp.Profile.Onion}))
}
// StartGroupConnections attempts to connect to all group servers (thus initiating reconnect attempts in the conectionsmanager)
// StartPeersConnections attempts to connect to peer connections
func (cp *cwtchPeer) StartPeersConnections() {
for _, contact := range cp.GetContacts() {
if cp.GetContact(contact).IsServer() == false {
cp.PeerWithOnion(contact)
}
}
}
// StartServerConnections attempts to connect to all server connections
func (cp *cwtchPeer) StartServerConnections() {
for _, contact := range cp.GetContacts() {
if cp.GetContact(contact).IsServer() {
cp.JoinServer(contact)
} else {
cp.PeerWithOnion(contact)
}
}
}