From 21290f5752926f732bb3197db8fd218a91c37a25 Mon Sep 17 00:00:00 2001 From: Erik Little Date: Sat, 7 Nov 2020 19:19:06 -0500 Subject: [PATCH] Start working on migration guide --- README.md | 41 +- Source/SocketIO/Engine/SocketEngine.swift | 5 + Usage Docs/15to16.md | 3 + docs/12to13.html | 71 ++- docs/15to16.html | 245 ++++++++ docs/Classes.html | 114 ++-- docs/Classes/OnAckCallback.html | 66 +- docs/Classes/SocketAckEmitter.html | 90 ++- docs/Classes/SocketAnyEvent.html | 66 +- docs/Classes/SocketEngine.html | 374 +++++++----- docs/Classes/SocketIOClient.html | 575 +++++++----------- docs/Classes/SocketManager.html | 294 ++++----- docs/Classes/SocketRawAckView.html | 60 +- docs/Classes/SocketRawView.html | 64 +- docs/Enums.html | 75 ++- docs/Enums/SocketAckStatus.html | 118 +++- docs/Enums/SocketClientEvent.html | 66 +- docs/Enums/SocketEnginePacketType.html | 56 +- docs/Enums/SocketIOClientOption.html | 120 ++-- docs/Enums/SocketIOStatus.html | 76 ++- docs/Enums/SocketParsableError.html | 64 +- docs/Extensions.html | 564 +++++++++++++++++ docs/Guides.html | 86 ++- docs/Protocols.html | 115 ++-- docs/Protocols/ConfigSettable.html | 66 +- docs/Protocols/SocketData.html | 70 ++- docs/Protocols/SocketDataBufferable.html | 64 +- docs/Protocols/SocketEngineClient.html | 96 ++- docs/Protocols/SocketEnginePollable.html | 82 ++- docs/Protocols/SocketEngineSpec.html | 229 ++++--- docs/Protocols/SocketEngineWebsocket.html | 111 +++- docs/Protocols/SocketIOClientSpec.html | 229 +++++-- docs/Protocols/SocketLogger.html | 78 ++- docs/Protocols/SocketManagerSpec.html | 207 ++++--- docs/Protocols/SocketParsable.html | 219 ++++++- docs/Structs.html | 63 +- docs/Structs/SocketEventHandler.html | 74 ++- docs/Structs/SocketIOClientConfiguration.html | 112 +++- docs/Structs/SocketPacket.html | 86 ++- docs/Structs/SocketPacket/PacketType.html | 74 ++- docs/Typealiases.html | 55 +- docs/css/jazzy.css | 45 +- docs/faq.html | 63 +- docs/index.html | 104 ++-- docs/js/jazzy.js | 63 +- docs/js/jazzy.search.js | 26 +- docs/js/jquery.min.js | 6 +- docs/js/lunr.min.js | 6 +- docs/js/typeahead.jquery.js | 262 ++++++-- docs/search.json | 2 +- 50 files changed, 4301 insertions(+), 1599 deletions(-) create mode 100644 Usage Docs/15to16.md create mode 100644 docs/15to16.html create mode 100644 docs/Extensions.html diff --git a/README.md b/README.md index 02e9994..c88b411 100644 --- a/README.md +++ b/README.md @@ -31,56 +31,23 @@ socket.on("currentAmount") {data, ack in socket.connect() ``` -## Objective-C Example -```objective-c -@import SocketIO; - -NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"]; -SocketManager* manager = [[SocketManager alloc] initWithSocketURL:url config:@{@"log": @YES, @"compress": @YES}]; -SocketIOClient* socket = manager.defaultSocket; - -[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) { - NSLog(@"socket connected"); -}]; - -[socket on:@"currentAmount" callback:^(NSArray* data, SocketAckEmitter* ack) { - double cur = [[data objectAtIndex:0] floatValue]; - - [[socket emitWithAck:@"canUpdate" with:@[@(cur)]] timingOutAfter:0 callback:^(NSArray* data) { - if ([[data[0] description] isEqualToString:@"NO ACK"]) { - // Handle ack timeout - } - - [socket emit:@"update" with:@[@{@"amount": @(cur + 2.50)}]]; - }]; - - [ack with:@[@"Got your currentAmount, ", @"dude"]]; -}]; - -[socket connect]; - -``` - ## Features -- Supports socket.io 2.0+ (For socket.io 1.0 use v9.x) -- Supports binary +- Supports socket.io 3.0+ (For socket.io 1.0 use v9.x, For socket.io 2.0 use 15.x) +- Supports Binary - Supports Polling and WebSockets - Supports TLS/SSL -- Can be used from Objective-C ## FAQS Checkout the [FAQs](https://nuclearace.github.io/Socket.IO-Client-Swift/faq.html) for commonly asked questions. + Checkout the [12to13](https://nuclearace.github.io/Socket.IO-Client-Swift/12to13.html) guide for migrating to v13+ from v12 below. +Checkout the [15to16](https://nuclearace.github.io/Socket.IO-Client-Swift/15to16.html) guide for migrating to v16+ from v15. ## Installation Requires Swift 4/5 and Xcode 10.x -If you need Swift 2.3 use the [swift2.3 tag](https://github.com/socketio/socket.io-client-swift/releases/tag/swift2.3) (Pre-Swift 4 support is no longer maintained) - -If you need Swift 3.x use v11.1.3. - ### Swift Package Manager Add the project as a dependency to your Package.swift: ```swift diff --git a/Source/SocketIO/Engine/SocketEngine.swift b/Source/SocketIO/Engine/SocketEngine.swift index 3464dc2..7c30d07 100644 --- a/Source/SocketIO/Engine/SocketEngine.swift +++ b/Source/SocketIO/Engine/SocketEngine.swift @@ -681,6 +681,11 @@ enum EngineError: Error { } extension SocketEngine { + /// Delegate method for WebSocketDelegate. + /// + /// - Parameters: + /// - event: WS Event + /// - _: public func didReceive(event: WebSocketEvent, client _: WebSocket) { switch event { case let .connected(headers): diff --git a/Usage Docs/15to16.md b/Usage Docs/15to16.md new file mode 100644 index 0000000..ae65981 --- /dev/null +++ b/Usage Docs/15to16.md @@ -0,0 +1,3 @@ +# Upgrading from v15 to v16 + +This guide will help you navigate the changes that were introduced in v16. diff --git a/docs/12to13.html b/docs/12to13.html index f04fe3e..554af86 100644 --- a/docs/12to13.html +++ b/docs/12to13.html @@ -20,7 +20,7 @@

- SocketIO Docs + SocketIO 16.0.0-beta2 Docs (100% documented)

@@ -49,6 +49,9 @@ + @@ -60,9 +63,6 @@ - @@ -109,6 +109,47 @@ + + - - -
-
  • @@ -457,7 +479,7 @@ See SocketEnginePollable

    A SocketManager is responsible for multiplexing multiple namespaces through a single SocketEngineSpec.

    Example:

    -
    let manager = SocketManager(socketURL: URL(string:"http://localhost:8080/")!)
    +
    let manager = SocketManager(socketURL: URL(string:"http://localhost:8080/")!)
     let defaultNamespaceSocket = manager.defaultSocket
     let swiftSocket = manager.socket(forNamespace: "/swift")
     
    @@ -467,7 +489,7 @@ See SocketEnginePollable
     

    Sockets created through the manager are retained by the manager. So at the very least, a single strong reference to the manager must be maintained to keep sockets alive.

    -

    To disconnect a socket and remove it from the manager, either call SocketIOClient.disconnect() on the socket, +

    To disconnect a socket and remove it from the manager, either call SocketIOClient.disconnect() on the socket, or call one of the disconnectSocket methods on this class.

    NOTE: The manager is not thread/queue safe, all interaction with the manager should be done on the handleQueue

    @@ -487,46 +509,14 @@ or call one of the disconnectSocket methods on this class.

-
-
    -
  • -
    - - - - SSLSecurity - -
    -
    -
    -
    -
    -
    -

    A wrapper around Starscream’s SSLSecurity that provides a minimal Objective-C interface.

    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    open class SSLSecurity : NSObject
    - -
    -
    -
    -
    -
  • -
-
diff --git a/docs/Classes/OnAckCallback.html b/docs/Classes/OnAckCallback.html index 20934fb..31a4ec4 100644 --- a/docs/Classes/OnAckCallback.html +++ b/docs/Classes/OnAckCallback.html @@ -21,7 +21,7 @@

- SocketIO Docs + SocketIO 16.0.0-beta2 Docs (100% documented)

@@ -50,6 +50,9 @@ + @@ -61,9 +64,6 @@ - @@ -110,6 +110,47 @@ + +
+ + +
  • @@ -854,9 +914,9 @@ If using Swift it’s recommended to use init(socketURL: NSURL, option
  • @@ -881,9 +941,9 @@ If using Swift it’s recommended to use init(socketURL: NSURL, option
  • @@ -930,9 +990,9 @@ releasing.

  • @@ -981,7 +1041,7 @@ releasing.

    - emitAll(clientEvent:data:) + emitAll(clientEvent:data:)
    @@ -989,7 +1049,7 @@ releasing.

    -

    Sends a client event to all sockets in nsps

    +

    Sends a client event to all sockets in nsps

    @@ -1027,7 +1087,7 @@ releasing.

    - emitAll(_:_:) + emitAll(_:_:)
    @@ -1080,72 +1140,12 @@ releasing.

  • -
  • -
    - - - - emitAll(_:withItems:) - -
    -
    -
    -
    -
    -
    -

    Sends an event to the server on all namespaces in this manager.

    - -

    Same as emitAll(_:_:), but meant for Objective-C.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    open func emitAll(_ event: String, withItems items: [Any])
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - event - - -
    -

    The event to send.

    -
    -
    - - items - - -
    -

    The data to send with this event.

    -
    -
    -
    -
    -
    -
  • @@ -1191,7 +1191,7 @@ releasing.

    - engineDidError(reason:) + engineDidError(reason:)
    @@ -1237,7 +1237,7 @@ releasing.

    - engineDidOpen(reason:) + engineDidOpen(reason:)
    @@ -1281,9 +1281,9 @@ releasing.

  • @@ -1298,7 +1298,7 @@ releasing.

    Declaration

    Swift

    -
    open func engineDidReceivePong()
    +
    open func engineDidReceivePing()
    @@ -1308,9 +1308,9 @@ releasing.

  • @@ -1325,7 +1325,7 @@ releasing.

    Declaration

    Swift

    -
    open func engineDidSendPing()
    +
    open func engineDidSendPong()
    @@ -1337,7 +1337,7 @@ releasing.

    - engineDidWebsocketUpgrade(headers:) + engineDidWebsocketUpgrade(headers:)
    @@ -1383,7 +1383,7 @@ releasing.

    - parseEngineMessage(_:) + parseEngineMessage(_:)
    @@ -1429,7 +1429,7 @@ releasing.

    - parseEngineBinaryData(_:) + parseEngineBinaryData(_:)
    @@ -1473,9 +1473,9 @@ releasing.

  • @@ -1503,9 +1503,9 @@ releasing.

  • @@ -1559,7 +1559,7 @@ method.

    - setConfigs(_:) + setConfigs(_:)
    @@ -1586,9 +1586,9 @@ method.

  • @@ -1602,7 +1602,7 @@ method.

    Sockets created from this method are retained by the manager. Call one of the disconnectSocket methods on this class to remove the socket from manager control. -Or call SocketIOClient.disconnect() on the client.

    +Or call SocketIOClient.disconnect() on the client.

    @@ -1647,8 +1647,8 @@ Or call -

    © 2019 Erik. All rights reserved. (Last updated: 2019-05-28)

    -

    Generated by jazzy ♪♫ v0.9.4, a Realm project.

    +

    © 2020 Erik. All rights reserved. (Last updated: 2020-11-07)

    +

    Generated by jazzy ♪♫ v0.13.5, a Realm project.

    diff --git a/docs/Classes/SocketRawAckView.html b/docs/Classes/SocketRawAckView.html index 472a0ef..b797d83 100644 --- a/docs/Classes/SocketRawAckView.html +++ b/docs/Classes/SocketRawAckView.html @@ -21,7 +21,7 @@

    - SocketIO Docs + SocketIO 16.0.0-beta2 Docs (100% documented)

    @@ -50,6 +50,9 @@ + @@ -61,9 +64,6 @@ - @@ -110,6 +110,47 @@
  • + + + + + + + + + + + - - -
    -
    • @@ -385,16 +405,12 @@
    • -
    -
    -
    -
    • @@ -407,7 +423,7 @@

      A SocketManagerSpec is responsible for multiplexing multiple namespaces through a single SocketEngineSpec.

      Example with SocketManager:

      -
      let manager = SocketManager(socketURL: URL(string:"http://localhost:8080/")!)
      +
      let manager = SocketManager(socketURL: URL(string:"http://localhost:8080/")!)
       let defaultNamespaceSocket = manager.defaultSocket
       let swiftSocket = manager.socket(forNamespace: "/swift")
       
      @@ -417,7 +433,7 @@
       

      Sockets created through the manager are retained by the manager. So at the very least, a single strong reference to the manager must be maintained to keep sockets alive.

      -

      To disconnect a socket and remove it from the manager, either call SocketIOClient.disconnect() on the socket, +

      To disconnect a socket and remove it from the manager, either call SocketIOClient.disconnect() on the socket, or call one of the disconnectSocket methods on this class.

      See more @@ -426,18 +442,13 @@ or call one of the disconnectSocket methods on this class.

      Declaration

      Swift

      -
      @objc
      -public protocol SocketManagerSpec : AnyObject, SocketEngineClient
      +
      public protocol SocketManagerSpec : AnyObject, SocketEngineClient
    - - -
    -
    • @@ -494,10 +505,6 @@ or call one of the disconnectSocket methods on this class.

    • -
    -
    -
    -
    • @@ -526,10 +533,6 @@ or call one of the disconnectSocket methods on this class.

    • -
    -
    -
    -
    • @@ -546,16 +549,16 @@ or call one of the disconnectSocket methods on this class.

      A marking protocol that says a type can be represented in a socket.io packet.

      Example:

      -
      struct CustomData : SocketData {
      +
      struct CustomData : SocketData {
          let name: String
          let age: Int
       
      -   func socketRepresentation() -> SocketData {
      +   func socketRepresentation() -> SocketData {
              return ["name": name, "age": age]
          }
       }
       
      -socket.emit("myEvent", CustomData(name: "Erik", age: 24))
      +socket.emit("myEvent", CustomData(name: "Erik", age: 24))
       
      See more @@ -579,8 +582,8 @@ or call one of the disconnectSocket methods on this class.

    diff --git a/docs/Protocols/ConfigSettable.html b/docs/Protocols/ConfigSettable.html index 5f29b85..dbab274 100644 --- a/docs/Protocols/ConfigSettable.html +++ b/docs/Protocols/ConfigSettable.html @@ -21,7 +21,7 @@

    - SocketIO Docs + SocketIO 16.0.0-beta2 Docs (100% documented)

    @@ -50,6 +50,9 @@ + @@ -61,9 +64,6 @@ - @@ -110,6 +110,47 @@ + + + + + + + + + + + + + + + +