Changeset 5465:d5e7bc292531 in roaraudio


Ignore:
Timestamp:
03/31/12 02:30:26 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

no longer use fixed protocol version (_ROAR_MESSAGE_VERSION=0).
protocol version is now used by setting in message object.
If using connection based req (roar_req()) it will use version from connection
object setting. The connection object get's a default from the config.
The config key is "protocolversion".
roard will answer in the same version as the request was send in.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/basic.h

    r5381 r5465  
    102102                                 void * userdata); 
    103103 
     104int roar_set_connection_version(struct roar_connection * con, int version); 
     105 
    104106int roar_sync         (struct roar_connection * con); 
    105107int roar_wait_msg     (struct roar_connection * con, int16_t seq, int16_t seqmask); 
  • include/libroar/config.h

    r5381 r5465  
    130130 char * daemonimage; 
    131131 int serverflags; 
     132 int protocolversion; 
    132133}; 
    133134 
  • libroar/basic.c

    r5428 r5465  
    451451 
    452452int roar_connect_none (struct roar_connection * con) { 
     453 struct roar_libroar_config * config = roar_libroar_get_config(); 
     454 
    453455 if ( con == NULL ) { 
    454456  roar_err_set(ROAR_ERROR_INVAL); 
     
    459461 con->refc        = 1; 
    460462 con->flags       = ROAR_CON_FLAGS_NONE; 
    461  con->version     = 0; 
     463 con->version     = _ROAR_MESSAGE_VERSION; 
    462464 con->cb_userdata = NULL; 
    463465 con->cb          = NULL; 
     
    470472 
    471473// con->flags |= ROAR_CON_FLAGS_VIO; 
     474 
     475 if ( config->protocolversion != -1 ) 
     476  roar_set_connection_version(con, config->protocolversion); 
    472477 
    473478 roar_err_set(ROAR_ERROR_NONE); 
     
    616621                                            void                   * userdata), 
    617622                                 void * userdata) { 
    618  if ( con == NULL ) 
    619   return -1; 
     623 if ( con == NULL ) { 
     624  roar_err_set(ROAR_ERROR_FAULT); 
     625  return -1; 
     626 } 
    620627 
    621628 con->cb       = cb; 
    622629 con->cb_userdata = userdata; 
     630 
     631 return 0; 
     632} 
     633 
     634int roar_set_connection_version(struct roar_connection * con, int version) { 
     635 if ( con == NULL ) { 
     636  roar_err_set(ROAR_ERROR_FAULT); 
     637  return -1; 
     638 } 
     639 
     640 if ( version == -1 ) 
     641  version = _ROAR_MESSAGE_VERSION; 
     642 
     643 if ( version < 0 ) { 
     644  roar_err_set(ROAR_ERROR_INVAL); 
     645  return -1; 
     646 } 
     647 
     648 con->version = version; 
     649 
     650 if ( version == 2 ) { 
     651  con->flags |= ROAR_CON_FLAGS_SUPPORT_V2; 
     652 } 
    623653 
    624654 return 0; 
  • libroar/config.c

    r5381 r5465  
    5858  config.connect_internal = NULL; 
    5959  config.daemonimage      = NULL; 
     60  config.protocolversion  = -1; // use default. 
    6061 
    6162  if ( home != NULL ) { 
     
    319320    ROAR_WARN("roar_libroar_config_parse(*): Unknown serverflag: %s", v); 
    320321   } 
     322  } else if ( !strcmp(k, "protocolversion") ) { 
     323   config->protocolversion = atoi(v); 
    321324  } else { 
    322325   ROAR_WARN("roar_libroar_config_parse(*): Unknown option: %s", k); 
  • libroar/proto.c

    r5463 r5465  
    7070 
    7171 headerlen = _ROAR_MESS_BUF_LEN; 
    72  
    73  mes->version = _ROAR_MESSAGE_VERSION; 
    7472 
    7573 buf[0] = mes->version; // first byte is always the version. 
     
    320318  return -1; 
    321319 
     320 if ( mes->version == _ROAR_MESSAGE_VERSION ) 
     321  mes->version = con->version; 
     322 
    322323 return roar_vreq2(vio, mes, data, errorframe); 
    323324} 
Note: See TracChangeset for help on using the changeset viewer.