Changeset 3714:a290c4185eb8 in roaraudio


Ignore:
Timestamp:
04/25/10 04:43:23 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

implemented simple client passing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/req.c

    r3696 r3714  
    291291 
    292292int req_on_passfh      (int client, struct roar_message * mes, char * data) { 
     293 int sock = clients_get_fh(client); 
     294 int16_t * d = (int16_t*)data; 
    293295 int fh; 
    294  int sock = clients_get_fh(client); 
     296 int i; 
    295297 
    296298 if ( (fh = roar_socket_recv_fh(sock, NULL, NULL)) == -1 ) 
    297299  return -1; 
    298300 
    299  if ( client_stream_set_fh(client, mes->stream, fh) == -1 ) { 
    300   close(fh); 
    301   return 1; 
    302  } 
    303  
    304  
    305  mes->datalen = 0; 
    306  mes->cmd     = ROAR_CMD_OK; 
    307  
    308  return 0; 
     301 if ( mes->stream != -1 ) { // stream pass: 
     302  if ( client_stream_set_fh(client, mes->stream, fh) == -1 ) { 
     303   close(fh); 
     304   return 1; 
     305  } 
     306 
     307  mes->datalen = 0; 
     308  mes->cmd     = ROAR_CMD_OK; 
     309 
     310  return 0; 
     311 } 
     312 
     313// non-stream pass: 
     314 
     315/* 
     316 0: Version,  16 
     317 1: Flags,    16 
     318 2: Protocol, 16 
     319 3: Byteorder 16 
     320 Options... 
     321*/ 
     322 
     323 if ( mes->datalen < 4*2 ) 
     324  return -1; 
     325 
     326 for (i = 0; i < 4; i++) { 
     327  d[i] = ROAR_NET2HOST16(d[i]); 
     328 } 
     329 
     330 if ( d[0] != 0 ) // version 
     331  return -1; 
     332 
     333 if ( d[1] != 0 ) // flags 
     334  return -1; 
     335 
     336 if ( d[2] != ROAR_PROTO_ROARAUDIO ) // protocol 
     337  return -1; 
     338 
     339 if ( d[3] != ROAR_BYTEORDER_NETWORK ) // byte order 
     340  return -1; 
     341 
     342 if ( (client = clients_new()) == -1 ) 
     343  return -1; 
     344 
     345 if ( clients_set_fh(client, fh) == -1 ) { 
     346  clients_delete(client); 
     347  return -1; 
     348 } 
     349 
     350 mes->datalen = 0; 
     351 mes->cmd     = ROAR_CMD_OK; 
     352 
     353 return -1; 
    309354} 
    310355 
Note: See TracChangeset for help on using the changeset viewer.