You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

2 years ago
  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 ping message. Only called in socket.io >3.
  42. func engineDidReceivePing()
  43. /// Called when the engine receives a pong message. Only called in socket.io 2.
  44. func engineDidReceivePong()
  45. /// Called when the engine sends a ping to the server. Only called in socket.io 2.
  46. func engineDidSendPing()
  47. /// Called when the engine sends a pong to the server. Only called in socket.io >3.
  48. func engineDidSendPong()
  49. /// Called when the engine has a message that must be parsed.
  50. ///
  51. /// - parameter msg: The message that needs parsing.
  52. func parseEngineMessage(_ msg: String)
  53. /// Called when the engine receives binary data.
  54. ///
  55. /// - parameter data: The data the engine received.
  56. func parseEngineBinaryData(_ data: Data)
  57. /// Called when when upgrading the http connection to a websocket connection.
  58. ///
  59. /// - parameter headers: The http headers.
  60. func engineDidWebsocketUpgrade(headers: [String: String])
  61. }