Results 1 to 7 of 7

Thread: My Ice Stats doesn't work??

  1. #1
    billwillman is offline Registered User
    Join Date
    Sep 2006
    Posts
    14

    My Ice Stats doesn't work??

    ICE:3.0.1
    VC++ 6.0

    I use Ice in dll.

    this is code in dll:

    My Stats Class:

    CStats_bytesSent stats_bytesSent;
    CStats_bytesReceived Stats_bytesReceived;



    class IceStats:virtual public Ice::Stats
    {
    public:


    virtual void bytesSent(const string &prot,Ice::Int num)
    {

    if(stats_bytesSent=NULL) return;
    stats_bytesSent(num);
    };

    virtual void bytesReceived(const string &prot,Ice::Int num)
    {

    if(Stats_bytesReceived=NULL) return;
    Stats_bytesReceived(num);
    };
    };



    typedef void (_stdcall *CPrintPos)(int result);

    int _stdcall loadice(int argc, char *argv[])
    {
    if(printpos==NULL)
    return ICE_CALLBACK_ERROR;

    try
    {

    ic=Ice::initialize(argc,argv);

    Ice::ObjectPrx base=ic->stringToProxy("print:default -p 10000");

    print=printIPrx::checkedCast(base);

    if(!print)
    throw "Invalid proxy";

    printcallback=new Cprintcallback();

    return 0;

    }
    catch(const char *msg)
    {

    unloadice();
    return -2;
    }
    };


    int _stdcall sendmessage(int Messageid,void* Point)
    {
    switch(Messageid)
    {
    case ICE_FUNCTION_POINT:
    {

    printpos=CPrintPos(Point);

    break;
    }
    case ICE_Request_Print:
    {

    print->print_async(printcallback);

    break;
    }
    case ICE_STATS_ENABLE:
    {
    if(!ic) return ICE_STATS_ERROR;
    if(!stats)
    stats=new IceStats();

    ic->setStats(stats);

    }
    case ICE_STATS_SEND:
    {
    if((Point=NULL)||(!ic)||(!stats)) return ICE_STATS_ERROR;
    stats_bytesSent=CStats_bytesSent(Point);
    }
    case ICE_STATS_RECEIVED:
    {
    if((Point=NULL)||(!ic)||(!stats)) return ICE_STATS_ERROR;
    Stats_bytesReceived=CStats_bytesReceived(Point);
    }
    }
    return 0;
    };

    external Application:
    step :
    1.sendmessage(ICE_FUNCTION_POINT,callback);
    2.loadice(0,nil);
    3.sendmessage(ICE_STATS_ENABLE,nil);
    4.sendmessage(ICE_STATS_SEND,Stats_bytesSent));
    5.sendmessage(ICE_STATS_RECEIVED,Stats_bytesReceiv ed));
    6.sendmessage(ICE_Request_Print,nil);
    ·············
    7.unloadice();


    But My Ice Stats doesn't Work.
    My Full Name:
    zeng yi

    E-Mail:
    zengyi@vip.371.net

    My Company URL:
    www.zzia.edu.cn

    My Project:
    Games' net

    I use Ice in Visual C++.

  2. #2
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    You must set your stats object on the communicator right after communicator initialization. I recommend to use Ice 3.1, which has different initialization methods that avoid this mistake.

  3. #3
    billwillman is offline Registered User
    Join Date
    Sep 2006
    Posts
    14
    I have down ICE 3.1.But when use ic->setStat,the information tell me this function is not exist.How to use Ice::Stats??
    My Full Name:
    zeng yi

    E-Mail:
    zengyi@vip.371.net

    My Company URL:
    www.zzia.edu.cn

    My Project:
    Games' net

    I use Ice in Visual C++.

  4. #4
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Communicator::setStats() does not exist anymore in Ice 3.1. You must set it during initialization. Please see "30.3 Communicator Initialization" in the Ice manual.

  5. #5
    billwillman is offline Registered User
    Join Date
    Sep 2006
    Posts
    14
    Thank you for your answer.
    But now the Problem still exists.

    I Change my code:

    struct Ice::InitializationData initdata;

    sendmessage function changed:

    case ICE_STATS_ENABLE:
    {

    if(!initdata.stats)

    initdata.stats=new IceStats();
    break;


    }
    case ICE_STATS_SEND:
    {
    if(Point=NULL) return ICE_STATS_ERROR;
    stats_bytesSent=CStats_bytesSent(Point);
    break;
    }
    case ICE_STATS_RECEIVED:
    {
    if(Point=NULL) return ICE_STATS_ERROR;
    Stats_bytesReceived=CStats_bytesReceived(Point);
    break;
    }
    }



    loadice function changed:

    ic=Ice::initialize(initdata);

    But when i call loadice function,the exception is called.
    My Full Name:
    zeng yi

    E-Mail:
    zengyi@vip.371.net

    My Company URL:
    www.zzia.edu.cn

    My Project:
    Games' net

    I use Ice in Visual C++.

  6. #6
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    I'm afraid I don't understand what you mean. What exception is raised? What exactly isn't working?

  7. #7
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Also, you cannot set the stats object in your sendmessage() operation. As explained before, you must set it for initialization. You cannot change the stats object after initialization, i.e., the reference to the stats object is immutable. If you need to switch on and off stats, then you must do this directly in your implementation of the Ice::Stats interface.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 06-29-2009, 09:00 AM
  2. Slice2Java plugin doesn't work with Ice 3.3.0
    By gsteele9 in forum Help Center
    Replies: 3
    Last Post: 03-03-2009, 09:37 AM
  3. Replies: 5
    Last Post: 12-04-2006, 12:41 PM
  4. IcePHP doesn't work (nor compile) with PHP 5.1.4
    By g00fy in forum Bug Reports
    Replies: 0
    Last Post: 06-19-2006, 03:05 AM
  5. icepacknode doesn't work after reboot! help!
    By soloman817 in forum Help Center
    Replies: 4
    Last Post: 05-10-2005, 06:15 AM

Posting Permissions

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