Download BREW Developer Training

Transcript
BREW® Developer Training
Procedure
Follow these steps to complete the exercise:
1. Launch the BREW Resource Editor from within the Start Menu or from the Tool Bar in
Visual C++. Open the myapp.brx file in your myapp directory.
2. Select New String from the toolbar or Resource/New String from the menu.
3. Add the string “Socket Connection“ with the respective resource name
IDS_SOCKET_CONNECT.
4. Rebuild the myapp.bar file.
5. Launch Visual C++ if you have not done so.
6. Include “AEENet.h” in your application.
7. Add the following variables to your applet structure.
AEEDNSResult
AEECallback
dnsResult;
// DNS Result Structure
dnsCallback;
// Callback for DNS
INetMgr
*pINetMgr;
// InetMgr interface
ISocket
*pISocket;
// ISocket interface
char
webServer[50];
// Web server name
char
htmlReply[256];
// Buffer for HTML reply.
8. Add APP_STATE_SOCKET to your enum list of application states.
9. Add the following function prototypes to your code.
void MakeConnection(myapp *pMe, const char *webServer);
void DNSResultCB(myapp *pMe);
void ConnectionMade(myapp *pMe, int error);
void SendDataCB(myapp *pMe);
void ReadDataCB(myapp *pMe);
10. For the EVT_COMMAND event in your event handler, call MakeConnection(pMe,
“webber2.qualcomm.com“) in a case statement for IDS_SOCKET_CONNECT.
11. Add APP_STATE_SOCKET to your case statements that handle the clear key (AVK_KEY
event).
12. Call ISHELL_CreateInstance() in your myapp_InitAppData() function to open
the INetMgr interface with AEECLSID_NET. Use InetMgr to open the socket using
AEE_SOCK_STREAM. Release both interfaces in your myapp_FreeAppData() function.
13. Call IMENUCTL_AddItem() in DisplayMainMenu() to add resource string
IDS_SOCKET_CONNECT to the menu.
QUALCOMM Confidential and Proprietary
314