On-the-fly "Hello world" with Eclipse (page 3 of 5)
Step-by-Step develop an iPush client with Eclipse
Step 8 - New an instance of class iPush2Link - ip1
It's time to new an instance of iPush2Link, the main object for communicating with iPush Server.
If you have never developed any iPush application, you may ask: how do I know the exact class name of iPush API?
Don't worry, you can find class name easily with Code Assist of Eclipse.
(a) Type private com.icetech.ipush2. (the package name) at the first line of the class iPushDemo implements iPush2MsgListener, like Figure 13 shown.
(b) Code Assist will show you all classes and interfaces matched.
(c) Choose iPush2Link.

Figure 13. use Code Assist to help programming
(d) Code Assist will automatically fill the name of the chosen class (iPush2Link here).

Figure 14. Code Assist will automatically fill the name of the chosen class
(e) Declare ipl is an instance of class iPush2Link and create it.
|
private iPush2Link ip1 = new iPush2Link(); |

Figure 15. declare ip1 is an instance of class iPush2Link
Step 9 - Declare an integer to store connection ID
Each client will get an unique connection ID after it connects to iPush Server successfully.
We declare an integer variable named connId to store the connection ID. The connection ID is very important because you need it to present the client in many invoked methods after the client got connected.

Figure 16. variable connId will be used to store the connection ID
Step 10 - Connect to iPush Server
We are going to connect to iPush Server in the constructor iPushDemo().
(a) Make ipl invoke ipushTCPConnect() to connect to iPush Server and assign the return value to connId.
|
connId = ip1.ipushTCPConnect(); |

Figure 17. Type connId = ip1.ipushT to trigger the Code Assist for auto-completing.
Step 11 - See the arguments needed
Code Assist will show the 9 arguments (arg0~8) needed. They are:
- iPush2MsgListener
- iPush Server IP
- iPush Server Port
- Proxy IP
- Proxy Port
- Group
- Product
- Username
- Password

Figure 18. 9 arguments needed for connecting to iPush Server
Step 12 - Give the value of arguments
For proceeding this example, we had created a demo service and account in ICE Technology's public iPush Server.
- iPush2MsgListener: this
- iPush Server IP: "www.icetechnology.com"
- iPush Server Port: 8000
- Proxy IP: "" (depend on your network environment. Empty string means no proxy used here.)
- Proxy Port: 0 (depend on your network environment. 0 means no proxy used here.)
- Group: "ICE"
- Product: "iPush"
- Username: "eclipse"
- Password: "eclipse"
|
ip1.ipushTCPConnect(this,"www.icetechnology.com",8000,"",0,"ICE","iPush","eclipse","eclipse"); |

Figure 19. give the value of arguments with demo account or your own
To avoid receiving unexpected messages (from others use this demo account too), we encourage you to use your own iPush account. ICE Technology provides two ways of getting free iPush accounts:
- Apply Quick Start service of ICE Technology
- Download and get a free trial license to install your own iPush Server
Both need you to be a member of ICE Developer Center first.
| Page 3 of 5 | 1 2 3 4 5 |