:::: MENU ::::

Getting Started with Respoke: Part 2 – Connecting to Respoke

This entry is part 2 of 2 in the series Getting Started with Respoke

Welcome to Part 2 of of the Getting Started with Respoke Series! In this section we will be covering creating an instance of the Respoke Client and connecting to Respoke.

In Part 1 of this series, we walked through setting up your Respoke account and creating your first App. If you haven’t done this yet, please take a moment to complete Part 1 now, as you will need these two items to follow along in the rest of the series.

Creating the Respoke Client:

Respoke App Settings

The first thing you will want to do when creating your Application is to create an instance of the Respoke Client. But before you can do this, you will need to get your App ID. The App ID can be found by going to Developer Portal, selecting the “Apps” tab on the left, clicking on the settings icon of the app you are working on, and scrolling down to the App ID section.

Respoke App ID

Once you have your App ID, you’re ready to create your Client object. You do this by calling the createClient method of the respoke class as follows:

Note: We add the developmentMode parameter since we are operating in developmentMode which allows us to directly create Respoke access tokens without verification (more on this here: https://docs.respoke.io/tutorials/brokered-auth.html).

Connecting to Respoke:

Now that you have your shiny new Client object, let’s use it to connect to Respoke! We do this by calling the connect method of the Client object, and passing in an object containing a single parameter: endpointId. The endpointId is essentially a username, it can really be anything you want, but it is the name that other users in your app will identify you by. For this example I’m going to go with “trogdor”. While we’re at it, let’s also add a listener for the connect event, so that we get notified when our connection is successfully made.

Wrapping up:

If you’ve been following along, you should now be connected to Respoke, and ready to start having your app do something cool! Having problems, you can always get help on the Respoke forums at: http://community.respoke.io/

In Part 3 of this series, we’re going to look at sending and receiving messages using the Client API.

Series Navigation<< Getting Started with Respoke: Part 1 – Signing Up and Creating Your First App


So, what do you think ?