Ignore:
Timestamp:
Feb 24, 2009, 10:06:43 PM (16 years ago)
Author:
Christoph Mayer
Message:

-autolinks impl. (funktioniert noch nicht komplett, macht aber im moment nichts schlechter)
-einige fixes im ablauf etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/PingPong.cpp

    r2473 r2483  
    1717// construction
    1818PingPong::PingPong() : pingId( 0 ) {
     19        Timer::setInterval( 5000 );
    1920}
    2021
     
    7071
    7172        // bind communication and node listener
    72         node->bind(this);
    73         node->bind(this, PingPong::PINGPONG_ID);
     73        node->bind( this );
     74        node->bind( this, PingPong::PINGPONG_ID);
    7475       
     76        // start the ping timer. if we are not
     77        // the initiator this will happen in onJoinCompleted
     78        if( isInitiator ) Timer::start();
     79
    7580        // ping pong started up...
    7681        logging_info( "pingpong started up ");
     
    8590        Timer::stop();
    8691
    87         // unbind listeners
     92        // unbind communication and node listener
    8893        node->unbind( this );
    8994        node->unbind( this, PingPong::PINGPONG_ID );
     
    108113
    109114        // start the timer to ping every second
    110         Timer::setInterval( 1000 );
    111115        Timer::start();
    112116}
     
    117121
    118122// communication listener
    119 bool PingPong::onLinkRequest(const NodeID& remote, Message* msg) {
     123bool PingPong::onLinkRequest(const NodeID& remote, const DataMessage& msg) {
    120124        return false;
    121125}
    122126
    123 void PingPong::onMessage(Message* msg, const NodeID& remote,
    124                 const LinkID& lnk = LinkID::UNSPECIFIED) {
     127void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) {
    125128
    126         PingPongMessage* pingmsg = msg->decapsulate<PingPongMessage> ();
     129        PingPongMessage* pingmsg = msg.getMessage()->decapsulate<PingPongMessage> ();
    127130
    128131        logging_info( "received ping message on link " << lnk.toString()
    129132                        << " from node " << remote.toString()
    130                         << ": " << pingmsg->toString() );
     133                        << ": " << pingmsg->info() );
    131134}
    132135
     
    142145        PingPongMessage pingmsg( pingId );
    143146        node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID );
    144 
    145147}
    146148
Note: See TracChangeset for help on using the changeset viewer.