Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

End-To-End Real-Time Communication

No description
by

Sven Haiges

on 27 August 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of End-To-End Real-Time Communication

end-to-end
realtime
communication
Sven Haiges
@hansamann
NFC
biergarten
with hybris
realtime
operational deadlines from
event to system response
=
realtime
as fast as possbible without
sacrifying battery life
=
idea
early
prototyping
GO
enhance
prototype
video
docs
prezi
the "process"
system overview
Touch NFC Tag to open and initialize app
Place Orders
Receive Notifications via GCM
Android Native Client
Receive orders from smartphone
Receive status updates from tablet
Route the communication
Gaelyk Web Framework
Display orders
Allow waiters to assign orders
Trigger status updates
Web Browser
Android
NFC
Cloud Messaging
google
spring mobile
RestTemplate
Gaelyk
web framework
Groovy
Gradle
build system
google
Channel API
jQuery Mobile
HTML, CSS, JavaScript
JavaScript Channel API
1
Launch
via NFC
2
Read
Tag &
Check
GCM Registration
3
Enter
Order
4
Send
Order
(REST)
5
Send
Order
(Channel API)
Accept
Order
...
6
Update
Order Status
(REST)
7
GCM Server
Push
Message
8
Deliver
Message
9
10
Display
Notification
end-to-end
benefits
customer
owner
no more standing in line

order updates

possibility to pay via phone
optimize workflow

user tracking and demographics

possibility to combine payment with coupons
<activity android:name=".activity.TableActivity" android:label="@string/app_name" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="beer/table" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Filter for NFC Intent
Cart cart = params[0];

RestTemplate rest = new RestTemplate();

String resourceURL = "http://biergarten.appspot.com/api/v1/biergarten/"
+ cart.getBeergarden() + "/" + cart.getTable() + "/orders";

MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("registration_id", getRegistrationID());
map.add("total", format.format(cart.getTotal()));

int prodIndex = 0;
for (LineItem item : cart.getLineItems()) {
map.add("id_" + prodIndex, item.getProduct().getId());
map.add("name_" + prodIndex, item.getProduct().getName());
map.add("qty_" + prodIndex, Integer.toString(item.getQuantity()));
prodIndex++;
}

return new JSONObject(rest.postForObject(resourceURL, map, String.class));
def index = 0
def lineitems = getLineItemsFromParams(params)

response.contentType='application/json'
def builder = new JsonBuilder()
builder {
success true
type 'order'
registration_id params.registration_id
biergarten params.biergarten
table params.table
items lineitems
}

builder.writeTo(out)

//send to channel
channel.send(params.biergarten, builder.toString())
var token = $(document.body).attr('data-channel');
console.log("Got Token: " + token);

var channel = new goog.appengine.Channel(token);
var socket = channel.open();
socket.onopen = onOpened;
socket.onmessage = onMessage;
socket.onerror = onError;
socket.onclose = onClose;


function onMessage(msg) {
var json = msg.data

var obj = $.parseJSON(json);
console.log(obj);

if (obj.type == 'order')
addOrder(obj);
else if (obj.type == '...')
doSomething(obj);
}
function notifyCustomer(params)
{
$.ajax({
url: '/api/v1/biergarten/' + $(document.body).data('biergarten') + '/orders/' + params.xorder_id + '/status',
type: 'POST',
data: params,
success: function(data, textStatus, jqXHR) {
console.log('Successfully notified customer...');
}
});
}
def api_key = 'Google Server API Key'

URL url = "https://android.googleapis.com/gcm/send".toURL()
def postMap = [
registration_id : params.registration_id,
collapse_key : params.biergarten
data.type : 'order_accepted'
data.waiter_name : 'Sarah'
]

HTTPResponse res = url.post(headers:['Authorization':"key=${api_key}"], params:postMap)

response.contentType='application/json'
def builder = new JsonBuilder()
builder {
success((res.responseCode == 200) ? true : false)
response res.text
}

builder.writeTo(out)
public class GCMReceiver extends BroadcastReceiver {
public void onReceive(Context ctx, Intent intent) {
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
String type = intent.getStringExtra("xtype");
Log.d("demo", "Received C2DM Message... xtype: " + type);
...

} else if (intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION")) {
Log.d("demo", "Received C2DM Registration...");
if (intent.getStringExtra("error") != null) {
Log.e("demo", "Error Code: " + intent.getStringExtra("error"));
} else {
String registrationID = intent.getStringExtra("registration_id");
SharedPreferences prefs = ctx.getSharedPreferences("prefs", Context.MODE_PRIVATE);
Editor editor = prefs.edit();
editor.putString("registration_id", registrationID);
editor.commit();
Log.d("demo", "Registration_id: " + registrationID);
}
}
}
private void checkC2DM() {
SharedPreferences prefs = getSharedPreferences("prefs", Context.MODE_PRIVATE);

if (prefs.getString("registrationID", null) == null) {
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender", "<project_id>");
startService(registrationIntent);
Log.d("demo", "Registered for C2DM...");
}
}
omni-channel
commerce
Q&A
Sven Haiges
@hansamann
600
employees
Munich
Gliwice
Montreal
200+
partners
500+
customers
techblog.hybris.com
Cloud Messaging
Channel API
create google APIs project
enable GCM service
note project ID and create server key
modify APP permissions in AndroidManifest.xml
receive registration ID
send to your server
look up registration ID
send requests with notification content to GCM server
1
2
3
setup
phone
server
create web page, add Channel JS API
create callback handler for messages
think about channel naming
1
setup
create unique token for each JS client
add token to web page, so JS client can pick it up
use ChannelService to send messages
pick up unique token to establish channel connection
parse incoming messages
2
server
3
tablet
demo
relax
if (getIntent().hasExtra(NfcAdapter.EXTRA_TAG)) {
Tag tag = getIntent().getExtras().getParcelable(NfcAdapter.EXTRA_TAG);

Ndef ndef = Ndef.get(tag);
NdefMessage message = ndef.getCachedNdefMessage();

NdefRecord record = message.getRecords()[0];
if (record.getTnf() == NdefRecord.TNF_MIME_MEDIA && new String(record.getType()).equals("beer/table")) {
try {
JSONObject obj = new JSONObject(new String(record.getPayload()));
String biergarten = obj.getString("biergarten");
int table = obj.getInt("table");
Cart.getInstance().setBeergarden(biergarten);
Cart.getInstance().setTable(table);
Log.i("demo", "Acquired biergarten: " + biergarten + " and table: " + table);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Paul
Sven
Jürgen
1980
2000
2020
touchpoints
mobile
results
tech knowledge
customer understanding
trade shows
conferences
articles
discussion
NFC book
industry contacts
business idea
APIs
social
mobile
NFC
SAAS
UIs
HTML5
responsive
OAuth2
native/hybrid/web
Big Data
Full transcript