Sfoglia il codice sorgente

Move while loop read to own function

Cameron Mc Gorian 8 anni fa
parent
commit
a8f95b9cfc
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      Sources/WebSockets.swift

+ 5 - 1
Sources/WebSockets.swift

@@ -94,11 +94,15 @@ public func websocket(
                 }
             }
             
-            do {
+            func read() throws {
                 while true {
                     let frame = try session.readFrame()
                     try handleOperationCode(frame)
                 }
+            }
+            
+            do {
+                try read()
             } catch let error {
                 switch error {
                 case WebSocketSession.Control.close: