force connect and timeout connect implemented

This commit is contained in:
duffyduck 2026-02-19 10:13:50 +01:00
parent 486cf6d239
commit 019c60689e
4 changed files with 17 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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]