Changeset 5465:d5e7bc292531 in roaraudio for libroar/basic.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.