force connect and timeout connect implemented
This commit is contained in:
@@ -49,6 +49,7 @@ func NewShareManager(client *Client) *ShareManager {
|
||||
client.OnRequestDevice = sm.handleRequestDevice
|
||||
client.OnReleaseDevice = sm.handleReleaseDevice
|
||||
client.OnTunnelData = sm.handleTunnelData
|
||||
client.OnClientLeft = sm.handleClientLeft
|
||||
|
||||
return sm
|
||||
}
|
||||
@@ -311,6 +312,22 @@ func (sm *ShareManager) handleReleaseDevice(busID, fromClient string) {
|
||||
sm.broadcastDeviceList()
|
||||
}
|
||||
|
||||
func (sm *ShareManager) handleClientLeft(msg *protocol.ClientLeft) {
|
||||
sm.mu.RLock()
|
||||
var toRelease []string
|
||||
for busID, share := range sm.active {
|
||||
if share.usedBy == msg.ClientID {
|
||||
toRelease = append(toRelease, busID)
|
||||
}
|
||||
}
|
||||
sm.mu.RUnlock()
|
||||
|
||||
for _, busID := range toRelease {
|
||||
log.Printf("[share] auto-releasing %s (client %s left)", busID, msg.ClientID[:8])
|
||||
sm.handleReleaseDevice(busID, msg.ClientID)
|
||||
}
|
||||
}
|
||||
|
||||
func (sm *ShareManager) handleTunnelData(tunnelID string, data []byte) {
|
||||
sm.mu.RLock()
|
||||
tunnel, exists := sm.tunnels[tunnelID]
|
||||
|
||||
Reference in New Issue
Block a user