Push4Free

to Learn - How to program with iPush

general concept

Software developers must know what API or SDK means. Since iPush Server is a middleware, a developer has to pick any iPush API suit with the programming language or tool he/she uses to develop an iPush application.

For high accessibility, ICE Technology provides various kinds of APIs to support main stream run-time environments and programming languages:

  • Flash Component Library (for ActionScript 2)
  • Flex Component Library (for ActionScript 3)
  • JavaScript Wrapper - PJAX
  • ActiveX Control for Windows 32
  • ActiveX Control for Windows CE (for CE 4.x and Pocket PC 2003)
  • Windows DLL
  • .NET Framework Library
  • .NET Compact Framework Library (for MS Smartphone and Mobile OS)
  • Java Class (for Java Application and Applet)
  • J2ME Class (for Java Midlet)
  • Linux C Library
  • Mac OS X C Library

There are high consistency functions for easy learning and porting between different APIs.

All API packages listed above can be downloaded from this site. And all packages have sample program (with source code) and prgramming guide included.

Login to iPush BackOffice for creating a new service and new users, then run the sample program immediately to connect to iPush Server and start to taste the way of send-and-receive messages.

We will illustrate the steps for tasting iPush messaging later in this page.

Then open and check the sample program source code in your programming tool. You may also see the respective programming guide on methods, events, properties, and others for reference.

data flow and programming skeleton

Following figure displays the command and data flows of one-to-many message broadcasting with iPush (applies Pub/Sub messaging model):

The programming skeleton of data sending and receiving with iPush API would like the table below:

Data sender programming skeleton Data receiver programming skeleton
1. ipushTCPConnect()
Connect to iPush Server with TCP.
ipushTCPConnect()
Connect to iPush Server with TCP.
2.

 

ipushSubSubject()
Subscribe specific subject to iPush Server.
3. ipushSendNPSubjectData()
Send data to iPush Server with specific subject.
4. onSubjectMessage()*
After receives the data pushed from iPush Server, the client API will trigger this event for data handling in application.

onSubjectMessage()* : the name of the callback function (event) on receiving a subject message gets a slight difference between APIs.

  • SetSubjectData() - in ActiveX Control APIs
  • OnSetSubjectData() - in .NET Framework and .NET Compact Framework APIs
  • onSubjectMessage() - in Java and Flash AS2 APIs
  • onSubjectData() - in Linux C and Windows DLL APIs

Of course, one iPush application can play both data sender and receiver roles which would adopt these two programming skeletons.

taste iPush messaging

Background information about server, service, and users

We have created one service and two users on public iPush Server of Push4Free with the following informtion. So you don't have to worry about the installing and configuring of iPush Server. It already there for you to taste.

Server

  • IP: www.push4free.com
  • Port: 443 (you should change the port from 8000 to 443 in figures below)

Service

  • Group: push4free
  • Product: taste
  • Limited Connections: 200

User 1

  • User ID: boy
  • Password: boy
  • Read Permission: push4free.taste.room1
  • Write Permission: push4free.taste.room1
  • Concurrent Use: 100

User 2

  • User ID: girl
  • Password: girl
  • Read Permission: push4free.taste.room1
  • Write Permission: push4free.taste.room1
  • Concurrent Use: 100

The read/write permissions tell both boy and girl can send and receive data on subject push4free.taste.room1, illustrates the basic concept of implementing real-time chatroom with iPush.

Download API package - take ActiveX Control for reference

Please download the latest iPush ActiveX Control API (ActiveX.zip). Then extract the zip file to any folder of your Windows system (say C:\taste) and open the subfolder ActiveX. It should look like this:

The subfolder vx.x.x (v2.4.14 here) means the version number of the iPush ActiveX Control API - xiPush2.ocx. You have to register it first.

Register xiPush2.ocx

Open [Start] / [Run] in your Windows system. Use the regsvr32 command to register the ActiveX control file xiPush2.ocx, like this:

If it does success, you can see the following message:

Run sample program - ActiveXSubjectSample.exe

1. Please open subfolder Samples and run two instances of ActiveXSubjectSample.exe. One for boy, the other for girl.

Input the respective information for connecting to public iPush Server, then press [Connect TCP] in both instances.

If connect and login to iPush Server successfully, you may see the responding message respectively:

Connect with TCP: Server[www.push4free.com], Port[8000], Group[push4free], Product[taste], User[boy], Password[boy]

Connect with TCP: Server[www.push4free.com], Port[8000], Group[push4free], Product[taste], User[girl], Password[girl]

=> method ipushTCP("www.push4free.com", 8000, "push4free", "taste", "boy", "boy") called

=> method ipushTCP("www.push4free.com", 8000, "push4free", "taste", "girl", "girl") called

2. In instance of gril, input push4free.taste.room1 for subject name, then press [Subscribe subject]:

If subscribe successfully, you may see the responding message:

Receive command msg: [700]push4free.taste.room1 - Subject Command OK
Subscribe to subject [push4free.taste.room1]

=> method ipushSubSubject("push4free.taste.room1") called

3. In instance of boy, input push4free.taste.room1 for subject name, hello, everyone for message, then press [Send subscribe msg]:

If send successfully, you may see the responding message:

Send string (length=15): hello, everyone

=> method ipushSendNPSubjectData("push4free.taste.room1", "hello, everyone") called

4. Soon after iPush Server receives the message sent from boy, it will push the message to girl since she has subscribed the subject push4free.taste.room1.

So the instance of girl will show the responding message upon subject message received:

Subject [push4free.taste.room1] received: (from=3,id=3127,length=15)hello, everyone

=> event SetSubjectData("push4free.taste.room1", "", "hello, everyone", 3, 3127) triggered

Feel free to play more on these two instances or run more ActiveXSubjectSample.exe instances to join the chatting. Have fun.

Site Info

Copyright 2007-2008, Sponsored by ICE Technology Corp.