0
import Swamp

class ViewController: UIViewController,SwampSessionDelegate,SwampTransportDelegate {

    let swampTransport = WebSocketSwampTransport(wsEndpoint:  URL(string: "wss://122.166.47.130:8086/ws")!)

    override func viewDidLoad() {
        super.viewDidLoad()
        connect()
    }

    func connect(){
        swampTransport.delegate = self
        let swampSession = SwampSession(realm: "open-realm", transport: swampTransport)
    //    let swampSession = SwampSession(realm: <#T##String#>, transport: <#T##SwampTransport#>, authmethods: <#T##[String]?#>, authid: <#T##String?#>, authrole: , authextra: <#T##[String : Any]?#>)


        swampSession.delegate = self
        swampSession.connect()
    }

    func swampSessionHandleChallenge(_ authMethod: String, extra: [String: Any]) -> String{
        print("swampSessionHandleChallenge")
      return ""
    }

    func swampSessionConnected(_ session: SwampSession, sessionId: Int){
        print("swampSessionConnected")
        session.subscribe("wamp.topic", onSuccess: { subscription in
            print("sssddf")
        }, onError: { details, error in
            print("errorrrr")
        }, onEvent: { details, results, kwResults in
            print("aaaaaa")
        })

    }

    func swampSessionEnded(_ reason: String){
        print("swampSessionEnded= \(reason)")

    }

    public func swampTransportDidConnectWithSerializer(_ serializer: SwampSerializer){
        print("swfdgfsdg")
    }

    public func swampTransportDidDisconnect(_ error: NSError?, reason: String?){
        print("retryw")
    }

    public func swampTransportReceivedData(_ data: Data){
        print("uu7i7")
    }
}

私は例外を取得しています:

CFNetwork SSLHandshake の失敗 (-9807)

追加したレルムの値は正しいと思いますが、確かではありません。Print()その接続をテストするために使用されます。

4

1 に答える 1