Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    67

    About Async Client/Server

    Recently, I'd like to implement an application based async client/server:

    - on server side, it monitors the newly incoming events(e.g. sms, call, etc.). When a new events occurs and caught on server side, it send a notification to the client.

    - on client side, it starts the server process and creates the session with the server. And also automatically popup a note/dialog to display the newly incoming event info sent from the server.

    Generally, I plan to leverage CSession2/RSessionBaseto implement the async client/server. I refer to the article "Asynchronous Client/Server Example" and the example "ClientServerAsyc" in the SDK. However, I still have no very clear idea on how to implement it. Especailly, regarding the notification, how does the server communicate with the client? Should the client create an CActive which polls and checks if there is new notification?

    So, would you please help to give me some good suggestions on my requirement? It will be great if you can paste some sample code or pseudocode.

    Your help are very appreciated!

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: About Async Client/Server

    Yes, that's how all the system servers work (including the ones you will use to get notification about sms, call, etc..): a client opens a session, issues a asynchronous request for notifications and then will "sleep" until the RunL method is called after which it will issue a new request...
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    67

    Re: About Async Client/Server

    Quote Originally Posted by ltomuta View Post
    Yes, that's how all the system servers work (including the ones you will use to get notification about sms, call, etc..): a client opens a session, issues a asynchronous request for notifications and then will "sleep" until the RunL method is called after which it will issue a new request...
    Thanks for the kindly reply! Pre your comments, the following is my base thought of the implementation. Please help to review it and propose your suggestions if possible:

    On the client side:
    enum TEventType {
    EIncomingEvent1, EIncomingEvent2, ...
    }

    enum TRequestCmdIds {
    EListen, ECancelRequest, ...}

    CServerSession iServSession;

    ClientIpcHandler::RunL() {

    switch(iStatus.Int) {
    case EIncomingEvent1:
    // handle the event
    ListenL();
    case EIncomingEvent2:

    case ...

    }
    }

    ClientIpcHandler::ListenL(TInt& aEventType, TDes aMessage) {
    // Wait a monent
    HeartBeat ...

    if(!IsActive()) {
    iServSession.Listen(aEvent, aMessage, iStatus);
    SetActive();
    }

    }
    ...
    /////////////////////////////////////
    CServerSession::Listen(TInt& aEventType, TDes aMessage, TRequstStatus aStatus) {
    TIpcArgs args(&aEventType, &aMessage);
    SendReceive(EListen, args, aStatus);
    }
    On the server side:


    CSession iSession;

    void CServer::SendIncommingEventToSessions(TEventType aEvent)
    {
    iSessionIter.SetToFirst();
    CInfoGuardSession* session;
    session = reinterpret_cast<CInfoGuardSession*> (iSessionIter++);
    while (session)
    {
    session->SendIncommingEventToClient(aEvent);
    session = reinterpret_cast<CInfoGuardSession*> (iSessionIter++);
    }
    }

    /////////////////////////////////

    RMessage2 iMessage;

    CSession::SendIncommingEventToClient(TEventType aEvent) {
    iMessage.WriteL(...); // Write event type
    iMessage.WriteL(...); // Write message
    iMessage.Complete(ESettingsUpdateComplete);
    }

    void CSession::ServiceL(const RMessage2& aMessage)
    {
    switch (aMessage.Function())
    {
    case EListening:
    iMessage = aMessage;
    // Invoking async method to listen
    break;
    case ECancelRequest:
    // Handling cancel
    break;
    default:
    PanicClient(aMessage, EBadRequest);
    return;
    }
    aMessage.Complete(KErrNone);
    }
    ...

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,185

    Re: About Async Client/Server

    of course there could also be notifications from the server side, for more infomration check publish & subscripe APIs for Symbian..

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: About Async Client/Server

    Hi,

    It is always good to start with some working example code. Take a look some of your code.
    Always good to pass TDes as reference. Also we need to keep the object alive because the Server thread might read data later time. I am not sure if you are following these in your code.

    Code:
    ClientIpcHandler::ListenL(TInt& aEventType, TDes aMessage) {
    // Wait a monent
    HeartBeat ...
    
    if(!IsActive()) {
    iServSession.Listen(aEvent, aMessage, iStatus);
    SetActive();
    }

Similar Threads

  1. CMdaAudioOutputStream unexpected playback pauses on Nokia E51
    By pkolaczk in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-07-29, 15:13
  2. Replies: 2
    Last Post: 2009-05-29, 23:27
  3. Replies: 4
    Last Post: 2009-01-13, 20:00
  4. Replies: 6
    Last Post: 2006-12-21, 11:44
  5. Client/Server on OS 9.1
    By m00gl3 in forum Symbian
    Replies: 9
    Last Post: 2006-11-24, 18:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×