force connect and timeout connect implemented
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -49,6 +49,7 @@ func NewShareManager(client *Client) *ShareManager {
|
|||||||
client.OnRequestDevice = sm.handleRequestDevice
|
client.OnRequestDevice = sm.handleRequestDevice
|
||||||
client.OnReleaseDevice = sm.handleReleaseDevice
|
client.OnReleaseDevice = sm.handleReleaseDevice
|
||||||
client.OnTunnelData = sm.handleTunnelData
|
client.OnTunnelData = sm.handleTunnelData
|
||||||
|
client.OnClientLeft = sm.handleClientLeft
|
||||||
|
|
||||||
return sm
|
return sm
|
||||||
}
|
}
|
||||||
@@ -311,6 +312,22 @@ func (sm *ShareManager) handleReleaseDevice(busID, fromClient string) {
|
|||||||
sm.broadcastDeviceList()
|
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) {
|
func (sm *ShareManager) handleTunnelData(tunnelID string, data []byte) {
|
||||||
sm.mu.RLock()
|
sm.mu.RLock()
|
||||||
tunnel, exists := sm.tunnels[tunnelID]
|
tunnel, exists := sm.tunnels[tunnelID]
|
||||||
|
|||||||
Reference in New Issue
Block a user