Exemplo n.º 1
0
void Master::client_notify(pair <int, int> srv, bool extension) //notify client of server fail or chain extension
{
    char send_msg[MAXLINE];
    socklen_t len = sizeof(struct sockaddr_in);
    ms.packetize(send_msg, srv, !extension, extension);
    //printf("%s\n",send_msg);
    map<int, list<Client*> >::iterator it1 = clients.find(srv.first);
    for(list<Client *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
    {
        Sendto(sockfd_udp, send_msg, MAXLINE, 0, (SA*)&((*it2)->Getsockaddr()), len);
    }
    if (extension)
        printf("Push notification of chain extension to all clients sent\n");
    else
        printf("Push notification of server fail to all clients sent\n");
}