Changeset 447 in flair-src for trunk/lib


Ignore:
Timestamp:
Sep 16, 2021, 2:01:56 PM (4 weeks ago)
Author:
Sanahuja Guillaume
Message:

vrpnlite handle disconection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp

    r438 r447  
    128128    mutex->ReleaseMutex();
    129129  } else if (connectionType==VrpnClient::VrpnLite) {
    130     if(trackables.size()<0xffff) {
    131       uint16_t id=trackables.size();
     130    if(trackables.size()<INT16_MAX) {
     131      int16_t id=trackables.size()+1;//avoid 0; positive values for adding, negative for removing
    132132      mutex->GetMutex();
    133133      trackables.push_back(obj);
     
    162162void VrpnClient_impl::RemoveTrackable(VrpnObject_impl *obj) {
    163163  mutex->GetMutex();
     164  //send remove notification to vrpnlite
     165  if (connectionType==VrpnClient::VrpnLite) {
     166    for (size_t i = 0; i < trackables.size(); i++) {
     167      if(trackables.at(i)==obj) {
     168        int16_t id=-(i+1);//avoid 0; positive values for adding, negative for removing
     169       
     170        char char_array[obj->self->ObjectName().length() + sizeof(id)];
     171        strcpy(char_array, obj->self->ObjectName().c_str());
     172        dataSocket->HostToNetwork((char*)(&id),sizeof(id));
     173        memcpy(&char_array[obj->self->ObjectName().length()],&id,sizeof(id));
     174        dataSocket->SendMessage(char_array,obj->self->ObjectName().length() + sizeof(id));
     175        break;
     176      }
     177    }
     178  }
     179 
     180  //update vector
    164181  if (connectionType==VrpnClient::Vrpn || connectionType==VrpnClient::VrpnLite) {
    165182    for (vector<VrpnObject_impl *>::iterator it = trackables.begin();it < trackables.end(); it++) {
Note: See TracChangeset for help on using the changeset viewer.