Synaptop API Plugin for Construct 2

The Syanptop API object can allow a game to use functionality when run as an application on Synaptop. It is highly recommended that any application you create for Synaptop use this plugin on Construct 2.

All applications in Synaptop have the ability to add “subscribers”, as is set up in Synaptop’s Developer.

Important To Export: When using the plugin, it is required to modify construct’s exported html file (index.html in the folder you exported to). If you modified the html export files as recommended in the install instructions the only required change on export is to fill in the APP ID in index.html.  You will find this near the bottom of the <head> section, which should be around line 60.

The Small Text: This plugin works best when ran on Synaptop’s API.  It can be run natively on the web, but you won’t be able to use any of this plugin’s benefits while doing so.  It cannot be tested on Construct 2’s local host test driver.

Tutorial for Synaptop API plugin on Construct 2

>> You can follow the Video Tutorial to learn how to install and how to use this plugin on Construct 2

>> You can also read more about the API (not the plugin) from our API page.

Synaptop Conditions

API Loaded

Short form: This trigger is called once the Synaptop API is done loading.

Long form: When the Synaptop API is added to a project, the plugin automatically loads the API and calls synaptop.loaded(function(response){/*Code here*/}).  In this function it sets up the triggers for On Subscriber, On Disconnect and Receive Message, as well as setting the initial stat of the expressions numSubscribers, UserAgent and Device.  This trigger gets called once all of these things are set up and initialized.

Question Answered

This trigger gets called when a question given by the “Prompt question” action, was answered.  You can use this in conjunction with the “Answer” condition to determine if the user answered the question yes or no.

Answer

This returns true if the user answered a yes/no question as “Yes” or the ok/cancel question as “Ok”.  It returns false if they answered “No” or “Cancel” respectively.

On New Subscriber

This trigger gets called whenever a new subscriber joins the application.  This also updates the values returned by the expressions lastSubscriberName and lastSubscriberID.

On Subscriber Disconnect

This trigger gets called whenever a subscriber leaves the application.

Receive Message

This trigger gets called when the app detects an incoming broadcast from another subscriber.  Use the lastMessage expression to get the contents of this broadcast.

Get Friends Complete

This trigger gets called the app has completed the call of Get Online Friends. The data can be retrieved from the expressions NumFriends, FriendName and FriendID.

File Selected

This trigger gets called when the user exits the open file dialogue, whether it be because they selected a file to open or by selecting cancel.  This can be used in conjunction with the Valid File condition to determine if they actually did select a file to open.

Valid File

This condition returns true if the user selected a file with the Open File action.  If a valid file was selected, this updates the Filename, Extension and FileURL expressions.

Synaptop Actions

Close App

This closes the application.

Message

This creates a message box within Synaptop to display the message passed to it.

Open File

This allows the user to pick a file from their Synaptop to open.  It can be passed a specific file type to allow or allow any file type to be opened.

Open URL

This opens a page in Synapnet with the URL specified.

Prompt Question

This prompts a yes/no or ok/cancel dialog.  Once the user selects an answer the Question Answered condition triggers and the Answer condition determines if the user selected yes/ok or no/cancel.

Broadcast

This broadcasts a packet to all subscribers, or a subset there of.  This can be used in conjunction with the Receive Message condition to achieve a networked game or application.
The recipients string currently does nothing, all broadcasts are sent to all subscribers.

Get Online Friends

This gets information on the number, names and ids of online friends, but does it asynchronously.  Once the Get Friends Complete trigger happens, the API has finished updating information on the online friends (this happens almost instantly).

Start Chat

This opens a chat window in Synaptop between the user and the friend specified.  The chat window only appears on the user’s system until they actually type in a message to send to the friend.

Videochat

This calls the friend specified with Synaptop’s video chat.

Synaptop Expressions

lastMessage

Returns the last message received by a broadcast.  The result is a string.  It is suggested that you encode you parse this string in a call of Receive Message so that it’s not overwritten by a new message before you parse it.

Extension

This returns the extension of the last file opened with Open File.

Filename

This returns the full file name, including extension, of the last file opened with Open File.

FileURL

This returns the URL of the last file opened with OpenFile.

FriendID (x)

This gets the ID of the friend at location x in the array of friends returned by Get Online Friends.

FriendName (x)

This gets the full name of the friend at location x in the array of friends returned by Get Online Friends.

NumFriends

This returns the number of friends returned by Get Online Friends.  If you wish to iterate through all online friends, it is suggested that you use a System for loop, starting at index 0 and ending at index SynaptopAPI.NumFriends-1 as displayed below:

lastSubscriberID

This returns an ID number for the latest person to subscribe or disconnect.  Note that this is only one number, if someone subscribes and then someone else disconnects, it will store the data for the person who disconnected, if then another person subscribes, it will store the information for the new subscriber.  This id will be unique for each user, so it’s perfect for identifying their character in a multiplayer game.

lastSubscriberName

This returns the name of the latest person to subscribe or disconnect.  Similar to above, only one number is stored, which is the newest person to do either of these acts.

numSubscribers

This returns the number of users currently subscribed.

Device

This returns iPod, iPhone, iPad, BlackBerry, Android, or unknown.  If you need more information about the user’s device or agent, you can parse the user agent string.

UserAgent

This returns the user-agent details about the client as a string.

UserFName/UserLName

Returns the first and last name of the user’s Synaptop account.

UserNumber

This returns the user’s ID number.

Contact Us

We'd love to hear from you. Send us an email and we'll get back to you soon!