forked from cwtch.im/cwtch
1
0
Fork 0

on manageServerConnection, always start a new one (fetch) and the replace existing if, and close

This commit is contained in:
Dan Ballard 2019-02-11 17:09:47 -08:00
parent 1620621d89
commit 8959382449
1 changed files with 10 additions and 6 deletions

View File

@ -45,13 +45,17 @@ func (m *Manager) ManagePeerConnection(host string, engine *Engine) *PeerPeerCon
func (m *Manager) ManageServerConnection(host string, handler func(string, *protocol.GroupMessage)) {
m.lock.Lock()
_, exists := m.serverConnections[host]
if !exists {
psc := NewPeerServerConnection(m.acn, host)
go psc.Run()
psc.GroupMessageHandler = handler
m.serverConnections[host] = psc
psc, exists := m.serverConnections[host]
newPsc := NewPeerServerConnection(m.acn, host)
newPsc.GroupMessageHandler = handler
go newPsc.Run()
m.serverConnections[host] = newPsc
if exists {
psc.Close()
}
m.lock.Unlock()
}