Jelajahi Sumber

Move while loop read to own function

Cameron Mc Gorian 8 tahun lalu
induk
melakukan
a8f95b9cfc
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  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: