Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 7, 2011, 4:18:08 PM (14 years ago)
Author:
smerkli
Message:

done for today

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/masterserver2/src/libraries/network/MasterServer.cc

    r8163 r8202  
    5252  {
    5353    /* get an iterator */
    54     std::list<packet::ServerInformation>::iterator i;
     54    std::list<ServerListElem>::iterator i;
    5555
    5656    /* packet holder */
     
    6363      /* send this particular server */
    6464      /* build reply string */
    65       char *tosend = (char *)calloc( (*i).getServerIP().length()
     65      char *tosend = (char *)calloc( (*i).ServerInfo.getServerIP().length()
    6666          + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
    6767      if( !tosend )
     
    7070      }
    7171      sprintf( tosend, "%s %s", MSPROTO_SERVERLIST_ITEM,
    72           (*i).getServerIP().c_str() );
     72          (*i).ServerInfo.getServerIP().c_str() );
    7373
    7474      /* create packet from it */
     
    104104   */
    105105  void
    106   MasterServer::helper_pingServers( void )
     106  MasterServer::helper_cleanupServers()
    107107  {
    108108    /* get an iterator */
    109     std::list<packet::ServerInformation>::iterator i;
     109    std::list<ServerListElem>::iterator i;
     110
    110111    /* loop through list elements */
    111112    for( i = mainlist.serverlist.begin(); i
    112113        != mainlist.serverlist.end(); ++i )
    113114    {
    114       /* to be implemented, waiting for Oli to reply to my email - sandro */
    115    
     115      if( mainlist.serverlist.size() != 0 && (*i).peer &&
     116         ((*i).peer->state == ENET_PEER_STATE_DISCONNECTED ||
     117          (*i).peer->state == ENET_PEER_STATE_ZOMBIE ))
     118      { mainlist.delServerByName( (*i).ServerInfo.getServerName() );
     119        COUT(2) << "someone timed out.\n";
     120      }
    116121    }
    117122 
    118   }
    119 
    120   void
    121   MasterServer::helper_cleanupServers()
    122   {
    123     /* same as above. */
    124 
    125123  }
    126124
     
    165163
    166164    /* output that the disconnect happened */
    167     COUT(4) << (char*)event->peer->data << " disconnected.\n";
     165    COUT(2) << (char*)event->peer->data << " disconnected.\n";
    168166
    169167    /* create string from peer data */
     
    205203        MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) )
    206204      { /* register new server */
    207         mainlist.addServer( packet::ServerInformation( event ) );
     205        mainlist.addServer( packet::ServerInformation( event ),
     206          event->peer );
    208207       
    209208        /* tell people we did so */
     
    260259    }
    261260
    262     /* TODO schedule pings for servers somewhere here */
    263     /* Iterate through servers and send pings */
    264     helper_pingServers();
    265    
    266261    /* check for timed out pings and remove those guys from
    267262     * the server list
Note: See TracChangeset for help on using the changeset viewer.