         
     }
     
-    //MARK: Delegates -------------
+    //MARK: Delegates
     public func mdwamp(wamp: MDWamp!, sessionEstablished info: [NSObject : AnyObject]!) {
         print("Session Established!")
         delegate!.onJoin()

                }
        }
    }


    //MARK: OLD CODE
    public func register(endpoint: String, callback: (AnyObject... ) -> ()) {
        session.registerRPC(endpoint, procedure: { (wamp: MDWamp!, invocation: MDWampInvocation!) -> Void in

    }
    
    public func publish(endpoint: String, args: AnyObject...) {
        session.publishTo(endpoint, args: args, kw: [:], options: [:]) { (err: NSError!) -> Void in
            if let e = err {
                print("Error: ", e)
            }
        }
    }
    
    //    public func subscribe(endpoint: String, callback: (AnyObject...) -> ()) {
    //        session.subscribe(endpoint, onEvent: { (event: MDWampEvent!) -> Void in
    //            print("Sub came in: ", event)
    //
    //            //print("", event.subscription)
    //            //print("", event.publication)
    //            //print("", event.topic)
    //            print("", event.details)
    //            print("", event.arguments)
    //            //print("", event.argumentsKw)
    //            //print("", event.event)
    //
    //            callback(event.arguments)
    //
    //            }) { (err: NSError!) -> Void in
    //                if let e = err {
    //                    print("An error occured: ", e)
    //                }
    //                else {
    //                    print("Sub completed")
    //                }
    //        }
    //    }
    
    
    //MARK: Utility
    func extractArgs(args: [AnyObject]) -> [AnyObject] {
        // Extracts the arguments and attempts to cast them based on their appearance
        return args[0] as! [AnyObject]
        //        let a = args[0] as! NSArray
        //        let b = a[0] as! NSArray
        //        return b as [AnyObject]
    }
}


