using clientId in the public interface of admin instead of an internal
interface agentConnection.
This commit is contained in:
parent
95204a9f5b
commit
f3963288e3
@ -222,10 +222,15 @@ func (admin *Admin) RemoveAgent(publicId models.RendezVousId) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (admin *Admin) RemoveClient(client *clientConnection) error {
|
func (admin *Admin) RemoveClient(clientId models.ClientId) error {
|
||||||
admin.mutex.Lock()
|
admin.mutex.Lock()
|
||||||
defer admin.mutex.Unlock()
|
defer admin.mutex.Unlock()
|
||||||
|
|
||||||
|
client := admin.clients[clientId]
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("RemoveClient: client with id '%v' not found", string(clientId))
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Removing client: '%s' created at %s\n", client.Info.Guid,
|
log.Printf("Removing client: '%s' created at %s\n", client.Info.Guid,
|
||||||
client.Info.StartTime.Format(time.DateTime))
|
client.Info.StartTime.Format(time.DateTime))
|
||||||
// try to explicitly close connection to the agent.
|
// try to explicitly close connection to the agent.
|
||||||
|
@ -182,7 +182,7 @@ func (s *AdminTestSuite) Test_connectClient() error {
|
|||||||
|
|
||||||
// removing the client will close all connections, we test this by writing to the connections
|
// removing the client will close all connections, we test this by writing to the connections
|
||||||
// after removing the client.
|
// after removing the client.
|
||||||
err = s.admin.RemoveClient(clientConn)
|
err = s.admin.RemoveClient(clientConn.Info.ClientId)
|
||||||
s.Nil(err)
|
s.Nil(err)
|
||||||
buf := make([]byte, 10)
|
buf := make([]byte, 10)
|
||||||
_, err = clientConn.clientConnection.Write(buf)
|
_, err = clientConn.clientConnection.Write(buf)
|
||||||
|
@ -120,7 +120,7 @@ func (converge *MatchMaker) Connect(wsProxyMode bool,
|
|||||||
client, err := converge.admin.AddClient(publicId, conn)
|
client, err := converge.admin.AddClient(publicId, conn)
|
||||||
cleanUpFunc := func() {
|
cleanUpFunc := func() {
|
||||||
if client != nil {
|
if client != nil {
|
||||||
converge.admin.RemoveClient(client)
|
converge.admin.RemoveClient(client.Info.ClientId)
|
||||||
}
|
}
|
||||||
converge.logStatus()
|
converge.logStatus()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user