0001 // CloseCode.swift 0002 // 0003 // The MIT License (MIT) 0004 // 0005 // Copyright (c) 2015 Zewo 0006 // 0007 // Permission is hereby granted, free of charge, to any person obtaining a copy 0008 // of this software and associated documentation files (the "Software"), to deal 0009 // in the Software without restriction, including without limitation the rights 0010 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0011 // copies of the Software, and to permit persons to whom the Software is 0012 // furnished to do so, subject to the following conditions: 0013 // 0014 // The above copyright notice and this permission notice shall be included in all 0015 // copies or substantial portions of the Software. 0016 // 0017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0018 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0019 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0020 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0021 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0022 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 0023 // SOFTWARE. 0024 0025 public enum CloseCode{ 0026 case Normal
CloseCode.swift:44 case 1000: self = NormalCloseCode.swift:45 case 1001: self = GoingAwayCloseCode.swift:46 case 1002: self = ProtocolErrorCloseCode.swift:47 case 1003: self = UnsupportedCloseCode.swift:48 case 1005: self = NoStatusCloseCode.swift:49 case 1006: self = AbnormalCloseCode.swift:50 case 1007: self = UnsupportedDataCloseCode.swift:51 case 1008: self = PolicyViolationCloseCode.swift:52 case 1009: self = TooLargeCloseCode.swift:53 case 1010: self = MissingExtensionCloseCode.swift:54 case 1011: self = InternalErrorCloseCode.swift:55 case 1012: self = ServiceRestartCloseCode.swift:56 case 1013: self = TryAgainLaterCloseCode.swift:57 case 1015: self = TLSHandshakeSocket.swift:109 private let closeEventEmitter = EventEmitter<(code: CloseCode?, reason: String?)>()Socket.swift:150 public func close(code: CloseCode = .Normal, reason: String? = nil) throws {Socket.swift:442 let closeCode: CloseCode?Socket.swift:444 closeCode = CloseCode(code: rawCloseCode)0027 case GoingAway
CloseCode.swift:44 case 1000: self = NormalCloseCode.swift:64 case .Normal: return 1000Socket.swift:150 public func close(code: CloseCode = .Normal, reason: String? = nil) throws {Socket.swift:449 try close(closeCode ?? .Normal, reason: closeReason)0028 case ProtocolError
CloseCode.swift:45 case 1001: self = GoingAwayCloseCode.swift:65 case .GoingAway: return 10010029 case Unsupported
CloseCode.swift:46 case 1002: self = ProtocolErrorCloseCode.swift:66 case .ProtocolError: return 1002Socket.swift:227 try close(.ProtocolError)0030 case NoStatus
CloseCode.swift:47 case 1003: self = UnsupportedCloseCode.swift:67 case .Unsupported: return 10030031 case Abnormal
CloseCode.swift:48 case 1005: self = NoStatusCloseCode.swift:68 case .NoStatus: return 10050032 case UnsupportedData
CloseCode.swift:49 case 1006: self = AbnormalCloseCode.swift:69 case .Abnormal: return 10060033 case PolicyViolation
CloseCode.swift:50 case 1007: self = UnsupportedDataCloseCode.swift:70 case .UnsupportedData: return 10070034 case TooLarge
CloseCode.swift:51 case 1008: self = PolicyViolationCloseCode.swift:71 case .PolicyViolation: return 10080035 case MissingExtension
CloseCode.swift:52 case 1009: self = TooLargeCloseCode.swift:72 case .TooLarge: return 10090036 case InternalError
CloseCode.swift:53 case 1010: self = MissingExtensionCloseCode.swift:73 case .MissingExtension: return 10100037 case ServiceRestart
CloseCode.swift:54 case 1011: self = InternalErrorCloseCode.swift:74 case .InternalError: return 10110038 case TryAgainLater
CloseCode.swift:55 case 1012: self = ServiceRestartCloseCode.swift:75 case .ServiceRestart: return 10120039 case TLSHandshake
CloseCode.swift:56 case 1013: self = TryAgainLaterCloseCode.swift:76 case .TryAgainLater: return 10130040 case Raw
CloseCode.swift:57 case 1015: self = TLSHandshakeCloseCode.swift:77 case .TLSHandshake: return 1015(UInt16) 0041 0042 init
CloseCode.swift:58 default: self = .Raw(UInt16(code))CloseCode.swift:78 case .Raw(let code): return code(code: Int) { 0043 switch code { 0044 case 1000: self = Normal 0045 case 1001: self = GoingAway 0046 case 1002: self = ProtocolError 0047 case 1003: self = Unsupported 0048 case 1005: self = NoStatus 0049 case 1006: self = Abnormal 0050 case 1007: self = UnsupportedData 0051 case 1008: self = PolicyViolation 0052 case 1009: self = TooLarge 0053 case 1010: self = MissingExtension 0054 case 1011: self = InternalError 0055 case 1012: self = ServiceRestart 0056 case 1013: self = TryAgainLater 0057 case 1015: self = TLSHandshake 0058 default: self = .Raw(UInt16(code)) 0059 } 0060 } 0061 0062 var code: UInt16 { 0063 switch self { 0064 case .Normal: return 1000 0065 case .GoingAway: return 1001 0066 case .ProtocolError: return 1002 0067 case .Unsupported: return 1003 0068 case .NoStatus: return 1005 0069 case .Abnormal: return 1006 0070 case .UnsupportedData: return 1007 0071 case .PolicyViolation: return 1008 0072 case .TooLarge: return 1009 0073 case .MissingExtension: return 1010 0074 case .InternalError: return 1011 0075 case .ServiceRestart: return 1012 0076 case .TryAgainLater: return 1013 0077 case .TLSHandshake: return 1015 0078 case .Raw(let code): return code 0079 } 0080 } 0081 } 0082
Socket.swift:444 closeCode = CloseCode(code: rawCloseCode)