I am trying out the objectiveDDP library to connect my iOS app to my Meteor app. I am running my meteor app on localhost:3000
and I am getting this error when I try to login:
Error Domain=boundsj.objectiveddp.transport Code=0 "You are not connected" UserInfo=0x7fe33b440500 {NSLocalizedDescription=You are not connected}
*Note - I have not done anything to the server to support this, I assuming that it is supported out of the box.
I'm not sure if the url I put in is correct because I couldn't find the documentation for which url I should connect to when using ObjectiveDDP.
Here is my code:
var meteorClient: MeteorClient = MeteorClient(DDPVersion: "1")
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.meteorClient.addSubscription("someSubscription")
var ddp = ObjectiveDDP(URLString: "ws://localhost:3000/websocket", delegate: self.meteorClient)
self.meteorClient.ddp = ddp;
self.meteorClient.ddp.connectWebSocket()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "reportConnection", name: MeteorClientDidConnectNotification, object: nil)
}
func reportConnection() {
println("================> connected to server!")
println(self.meteorClient.connected)
self.meteorClient.logonWithEmail("[email protected]", password: "password", responseCallback: {
(response, error) -> Void in
if (error != nil) {
println("*****Error******")
println(error);
return;
}
println(response);
})
}
*Update
So I try to check whether my meteorClient
is connected to the server before I login. I added
NSNotificationCenter.defaultCenter().addObserver(self, selector: "reportConnection", name: MeteorClientDidConnectNotification, object: nil)
To get notify when I am connected. However, when the DidConnectNotification is receive, I check self.meteorClient.connected
and got false.
maintainer of said library, can you specify what versions of ObectiveDDP and meteor you are using? First try using ObectiveDDP from master not cocoapods. Your url is correct. First thing to check also, do the sample apps connect to your server?
Can you try your login by using a button instead, I think your hitting a race condition. This is something that could use a bit of tidy up.