|
|
@@ -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() |
|
|
|
} |
|
|
|
|
|
|
|