SocketEngineClient.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // SocketEngineClient.swift
  3. // Socket.IO-Client-Swift
  4. //
  5. // Created by Erik Little on 3/19/15.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. import Foundation
  26. /// Declares that a type will be a delegate to an engine.
  27. @objc public protocol SocketEngineClient {
  28. // MARK: Methods
  29. /// Called when the engine errors.
  30. ///
  31. /// - parameter reason: The reason the engine errored.
  32. func engineDidError(reason: String)
  33. /// Called when the engine closes.
  34. ///
  35. /// - parameter reason: The reason that the engine closed.
  36. func engineDidClose(reason: String)
  37. /// Called when the engine opens.
  38. ///
  39. /// - parameter reason: The reason the engine opened.
  40. func engineDidOpen(reason: String)
  41. /// Called when the engine receives a pong message.
  42. func engineDidReceivePong()
  43. /// Called when the engine sends a ping to the server.
  44. func engineDidSendPing()
  45. /// Called when the engine has a message that must be parsed.
  46. ///
  47. /// - parameter msg: The message that needs parsing.
  48. func parseEngineMessage(_ msg: String)
  49. /// Called when the engine receives binary data.
  50. ///
  51. /// - parameter data: The data the engine received.
  52. func parseEngineBinaryData(_ data: Data)
  53. /// Called when when upgrading the http connection to a websocket connection.
  54. ///
  55. /// - parameter headers: The http headers.
  56. func engineDidWebsocketUpgrade(headers: [String: String])
  57. }