示例#1
0
void HumanClientApp::HandleMessage(Message& msg) {
    if (INSTRUMENT_MESSAGE_HANDLING)
        std::cerr << "HumanClientApp::HandleMessage(" << msg.Type() << ")\n";

    switch (msg.Type()) {
    case Message::ERROR_MSG:                m_fsm->process_event(Error(msg));                   break;
    case Message::HOST_MP_GAME:             m_fsm->process_event(HostMPGame(msg));              break;
    case Message::HOST_SP_GAME:             m_fsm->process_event(HostSPGame(msg));              break;
    case Message::JOIN_GAME:                m_fsm->process_event(JoinGame(msg));                break;
    case Message::HOST_ID:                  m_fsm->process_event(HostID(msg));                  break;
    case Message::LOBBY_UPDATE:             m_fsm->process_event(LobbyUpdate(msg));             break;
    case Message::LOBBY_CHAT:               m_fsm->process_event(LobbyChat(msg));               break;
    case Message::SAVE_GAME_DATA_REQUEST:   m_fsm->process_event(SaveGameDataRequest(msg));     break;

    case Message::GAME_START:               m_fsm->process_event(GameStart(msg));               break;
    case Message::TURN_UPDATE:              m_fsm->process_event(TurnUpdate(msg));              break;
    case Message::TURN_PARTIAL_UPDATE:      m_fsm->process_event(TurnPartialUpdate(msg));       break;
    case Message::TURN_PROGRESS:            m_fsm->process_event(TurnProgress(msg));            break;
    case Message::PLAYER_STATUS:            m_fsm->process_event(::PlayerStatus(msg));          break;
    case Message::PLAYER_CHAT:              m_fsm->process_event(PlayerChat(msg));              break;
    case Message::DIPLOMACY:                m_fsm->process_event(Diplomacy(msg));               break;
    case Message::DIPLOMATIC_STATUS:        m_fsm->process_event(DiplomaticStatusUpdate(msg));  break;
    case Message::END_GAME:                 m_fsm->process_event(::EndGame(msg));               break;
    default:
        ErrorLogger() << "HumanClientApp::HandleMessage : Received an unknown message type \"" << msg.Type() << "\".";
    }
}
示例#2
0
char *WhereGr(FILE *fp,char *address, char *uqhn, char *domain, char *ipv4, char *ipv6)
{
 // This model of "where?" is based on IP addresses and portnumbers, for cloud services
 // alternative models for "other worlds" can be added...
 
 static char where[CGN_BUFSIZE] = {0};
 char attr[CGN_BUFSIZE];
 
 if (domain == NULL || strlen(domain) == 0)
    {
    domain = "unknown domain";
    }

  if (ipv6 && strlen(ipv6) > 0)
     {
     snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s ipv6 %s",uqhn,domain,ipv4,ipv6);
     }
  else
     {
     snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s",uqhn,domain,ipv4);
     }

  if (address && strlen(address) > 0)
     {
     snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s,address %s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6),address);
     }
  else
     {
     snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6));
     }

  RoleGr(fp,where,"where",attr, "host location identification");
  
  RoleGr(fp,Domain(domain),"dns domain name",domain,"host location identification");

  char *hostname = Hostname(uqhn);
  RoleGr(fp,hostname,"hostname",uqhn,"host location identification");
  Gr(fp,where,a_alias,hostname,"host location identification");  // Alias for quick association
  Gr(fp,Domain(domain),a_contains,hostname,"host location identification");

  char *identity = HostID(uqhn);
  Gr(fp,hostname,a_alias,identity,"host location identification");
  
  RoleGr(fp,IPv4(ipv4),"ipv4 address", ipv4,"host location identification");
  Gr(fp,where,a_alias,IPv4(ipv4),"host location identification");  // Alias for quick association
  Gr(fp,Domain(domain),a_contains,IPv4(ipv4),"host location identification");
  Gr(fp,IPv4(ipv4),a_alias,HostID(ipv4),"host location identification");

  if (ipv6 && strlen(ipv6) > 0)
     {
     RoleGr(fp,IPv6(ipv6),"ipv6 address", ipv6,"host location identification");
     Gr(fp,where,a_alias,IPv6(ipv6),"host location identification");  // Alias for quick association
     Gr(fp,Domain(domain),a_contains,IPv6(ipv6),"host location identification");
     identity = HostID(ipv6);
     Gr(fp,IPv6(ipv6),a_alias,identity,"host location identification");
     Gr(fp,hostname,a_alias,IPv6(ipv6),"host location identification");
     }

  if (address && address > 0)
     {
     char addressx[CGN_BUFSIZE];
     snprintf(addressx,CGN_BUFSIZE,"description address %s",address);
     RoleGr(fp,addressx,"description address",address,"host location identification");
     Gr(fp,Domain(domain),a_origin,addressx,"host location identification");
     Gr(fp,"description address",a_related_to,"street address","host location identification");
     }
  
  Gr(fp,hostname,a_alias,IPv4(ipv4),"host location identification");

  return where;
}