pusher / NWWebSocket

A WebSocket client written in Swift, using the Network framework from Apple.
MIT License
123 stars 25 forks source link

Update NWWebSocket.swift #43

Open ajinumoto opened 1 year ago

ajinumoto commented 1 year ago

Fix multiple NWConnection during migrateConnection

ajinumoto commented 1 year ago

Problem: Every time migrateConnection() is called, new NWConnection will be created. The problem appear if migrateConnection() is called multiple time, the previous NWConnection from migratedConnection variable is never closed and multiple NWConnection will be alive.

Solution change migratedConnection to global variable and make sure its cancel() and nil first before creating new one.