SneakSpeak

A messaging proof-of-concept prototype application for Android

SGN-35016 - Internet of things and media services

Created by Iiro Nykänen & Ville Vaarala

Presentation contents

  1. Project idea and motivation
  2. Project implementation
  3. Android application
  4. Sails.js backend & setting up your server
  5. IoT-integration
  6. What we learned?
  7. Possible future improvements

1. Project idea and motivation

Desire to do something with Android and/or Node.js

Started thinking how the most popular messaging applications have a closed source server, and may or may not do stuff with your data.

→ How about a messaging application that lets you host your own servers?

2. Project implementation

  • Android app - native code written in Kotlin
  • Node.js backend - written using Sails.js framework
  • Preliminary Iot-integration - Node.js package
  • Messaging done via HTTP- and GCM-messages

3. Android application

Provides ways to...

  • register to multiple servers
  • join or create channels
  • send and receive private and channel messages

The code is available in GitHub, but it doesn't exactly follow good conventions...

Registration

Private messaging

Creating a channel

Channel chat

Joining a channel

Iot-integration

4. Backend

The Stack

  • Server software: Node.js
  • Framework: Sails.js
  • Database: PostgreSQL

Users and channels are stored in the database.

Messages are just transmitted to the client app(s). They will never be stored in the database.

HTTP API

HTTP API provides endpoints for...

  • Registering users
  • Joining and creating channels
  • Sending chat messages

API is documented in the sp-server/README.md file.

GCM XMPP Connections


sails.hooks["sp-gcm"].sendToChannel(channel, sender, message);
sails.hooks["sp-gcm"].sendToUser(receiver, sender, message);
						

GCM is used to transmit chat messages to client devices.

For the SneakSpeak application we forked and modified an existing GCM XMPP library and also wrote a custom Sails.js hook for our project.

Host your own server


git clone https://github.com/SneakSpeak/sp-server.git
cd sp-server
npm install
					

Create a project for your server on Google Developer Console. Also add API key for your server.

Update Google Project Number, Server API Key and your database settings as instructed in README. Start the server:


npm start
					

5. Iot-integration

Connecting IoT device to SneakSpeak

$ npm install git+https://github.com/SneakSpeak/sp-thing.git

var sneakSpeak = require('sp-thing')(
  serverURL, userToken, channelID, thingName
);

var measurement = measureSomething();

sneakSpeak.send(measurement);
					

6. What we learned?

  • Messaging applications require quite a lot of logic code
  • Reading documentations is a pain in the bottocks
  • Quality of NPM packages might surprise you 😱
  • GCM is very unreliable
  • Debugging Android can be a infuriating

7. Possible future improvements

  • More maintainable codebase
  • Security improvements
  • Better Iot-integration
  • Removal of GCM, adoption of e.g. websockets

THE END

- Sources available in GitHub
- Demo server running on Heroku: sneakspeak.herokuapp.com
- Slides created using reveal.js, available at sneakspeak.github.io

Questions?