Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
AlessandroSpadoni
Contributor
7,538

In this blog i want to describe my new project on Sap Code Exchange : Abap Pusher ( https://cw.sdn.sap.com/cw/groups/abap-pusher )
With Abap Pusher we can use Html5 websockets for adding realtime functionalities in Abap World.

What is a WebSocket?

(from http://en.wikipedia.org/wiki/WebSocket )
WebSocket is a technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket. It is designed to be implemented in web browser and web servers but it can be used by any client or server application

What is Pusher?

Pusher ( http://pusher.com , docs here http://pusher.com/docs/ ) is a simple hosted API for quickly, easily and securely adding realtime bi-directional functionality via WebSockets to web and mobile apps, or any other Internet connected device.


Pusher web service will send our messages to all connected clients that have subscribed our channel (using Html5 WebSockets protocol).

What is Abap Pusher?

Abap Pusher is an abap project for publishing/triggering events from ABAP using  Pusher REST API . In these way we can push realtime events from Abap to Browsers or any other connected clients without using Ajax,long polling..etc…. Server will push the messages to all clients.
Pusher provides many client libraries (Javascript , iOs , Android , Ruby , Arduino ,..).In my examples  I used Javascript library ( http://pusher.com/docs/client_libraries ).

Main class is ZCL_PUSHER

A simple Example.

First of all we need a Pusher account : there are many plans but the “Sandbox” Free plan (20 max connection) is good for our demo purposes.
Exploring Pusher dashboard, we can create “Apps” (an app called “Main” is created by default ) and on tab “Api Access” we found App_id , Key Token and Secret Token.
These 3 parameters are mandatory to create a ZCL_PUSHER instance. The message can be in any format but Pusher recommends  JSON;we can create JSON Strings using Json Abap Document Class by Uwe Fetzer ( https://cw.sdn.sap.com/cw/groups/zjson)

You can optionally specify socket id to avoid duplicates (see http://pusherapp.com/docs/duplicates )

Server Side (Abap)

Trigger an event ( PROG ZDEMO_PUSHER )

Client Side (Javascript )

So I can connect to my simple page http://www.alessandrospadoni.it/test_pusher.html from Chrome and Ipod Touch (iOs , Safari).

Both clients are connected to Pusher websocket.

Now i execute ZDEMO_PUSHER and this is the result!

This solution can be very useful in all “Real Time” situations , for example a simple application that displays realtime stock levels to the customers. (watch this video  ).
This is a simple example using a channel that doesn’t need authentication (Public channels ).

I will write another blog about “private” channels,prefixed with “private-“, “presence” channels ,prefixed with “presence-“ (useful for Chat apps) and Pusher WebHooks.

update 5.11.2012

This is the link to the 2nd part about "Private Channels that needs an Authorization" : http://scn.sap.com/community/code-exchange/blog/2012/10/01/abap-pusher-abap-authorization-objects-an...

This is a simple video recorded for Sap Inside Track Milan about Public Channels:

Links:

Abap Pusher

Pusher docs

12 Comments
Labels in this area