Changeset 2517:183f9b04d767 in roaraudio


Ignore:
Timestamp:
09/01/09 15:23:53 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added very basic begin of multi protocol handling

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r1905 r2517  
    6161    *n->host = 0; 
    6262 
     63    n->proto = ROAR_PROTO_ROARAUDIO; 
     64 
    6365    n->acl   = NULL; 
    6466 
     
    158160 
    159161 g_clients[id]->gid = gid; 
     162 
     163 return 0; 
     164} 
     165 
     166int clients_set_proto (int id, int    proto) { 
     167 if ( g_clients[id] == NULL ) 
     168  return -1; 
     169 
     170 g_clients[id]->proto = proto; 
    160171 
    161172 return 0; 
     
    335346 roar_connect_fh(&con, g_clients[id]->fh); 
    336347 
    337  r = roar_recv_message(&con, &m, &data); 
    338  
    339  if ( r == -1 ) { // should we drop the client? 
    340   clients_delete(id); 
    341   return -1; 
    342  } 
    343  
    344  roar_debug_message_print(&m); 
    345  
    346  oldcmd = m.cmd; 
    347  
    348  if ( (r = command_exec(id, &m, data)) == -1 ) { 
    349   m.cmd     = ROAR_CMD_ERROR; 
    350   m.datalen = 0; 
    351   ROAR_DBG("clients_check(*): Exec of command faild!"); 
    352  } else { 
    353   if ( m.cmd == oldcmd ) { 
    354    m.cmd     = ROAR_CMD_OK; 
    355    m.datalen = 0; 
    356   } else if ( m.cmd == ROAR_CMD_OK_STOP ) { 
    357    m.cmd     = ROAR_CMD_OK; 
    358    rv        = 1; 
    359   } 
    360  } 
    361  
    362  roar_send_message(&con, &m, NULL); 
     348 switch (g_clients[id]->proto) { 
     349  case ROAR_PROTO_ROARAUDIO: 
     350    r = roar_recv_message(&con, &m, &data); 
     351 
     352    if ( r == -1 ) { // should we drop the client? 
     353     clients_delete(id); 
     354     return -1; 
     355    } 
     356 
     357    roar_debug_message_print(&m); 
     358 
     359    oldcmd = m.cmd; 
     360 
     361    if ( (r = command_exec(id, &m, data)) == -1 ) { 
     362     m.cmd     = ROAR_CMD_ERROR; 
     363     m.datalen = 0; 
     364     ROAR_DBG("clients_check(*): Exec of command faild!"); 
     365    } else { 
     366     if ( m.cmd == oldcmd ) { 
     367      m.cmd     = ROAR_CMD_OK; 
     368      m.datalen = 0; 
     369     } else if ( m.cmd == ROAR_CMD_OK_STOP ) { 
     370      m.cmd     = ROAR_CMD_OK; 
     371      rv        = 1; 
     372     } 
     373    } 
     374 
     375    roar_send_message(&con, &m, NULL); 
     376   break; 
     377  default: 
     378    rv = -1; 
     379 } 
    363380 
    364381 if ( data ) 
    365382  free(data); 
    366383 
    367  ROAR_DBG("clients_check(id=%i) = 0", id); 
     384 ROAR_DBG("clients_check(id=%i) = %i", id, rv); 
    368385 return rv; 
    369386} 
  • roard/include/client.h

    r767 r2517  
    6060int clients_set_gid   (int id, int    gid); 
    6161int clients_set_name  (int id, char * name); 
     62int clients_set_proto (int id, int    proto); 
    6263int clients_get       (int id, struct roar_client ** client); 
    6364int clients_get_fh    (int id); 
Note: See TracChangeset for help on using the changeset viewer.