Update session information from device response.

        Increment sequence number when starting stream, not when playing.
        If device requires authentication resend previous message with auth.
553598
def update(self, response):
        
        data = response.splitlines()
        _LOGGER.debug('Received data %s from %s', data, self.host)
        while data:
            line = data.pop(0)
            if 'RTSP/1.0' in line:
                self.rtsp_version = int(line.split(' ')[0][5])
                self.status_code = int(line.split(' ')[1])
                self.status_text = line.split(' ')[2]
            elif 'CSeq' in line:
                self.sequence_ack = int(line.split(': ')[1])
            elif 'Date' in line:
                self.date = line.split(': ')[1]
            elif 'Public' in line:
                self.methods_ack = line.split(': ')[1].split(', ')
            elif "WWW-Authenticate: Basic" in line:
                self.basic = True
                self.realm = line.split('"')[1]
            elif "WWW-Authenticate: Digest" in line:
                self.digest = True
                self.realm = line.split('"')[1]
                self.nonce = line.split('"')[3]
                self.stale = (line.split('stale=')[1] == 'TRUE')
            elif 'Content-Type' in line:
                self.content_type = line.split(': ')[1]
            elif 'Content-Base' in line:
                self.content_base = line.split(': ')[1]
            elif 'Content-Length' in line:
                self.content_length = int(line.split(': ')[1])
            elif 'Session' in line:
                self.session_id = line.split(': ')[1].split(";")[0]
                if '=' in line:
                    self.session_timeout = int(line.split(': ')[1].split('=')[1])
            elif 'Transport' in line:
                self.transport_ack = line.split(': ')[1]
            elif 'Range' in line:
                self.range = line.split(': ')[1]
            elif 'RTP-Info' in line:
                self.rtp_info = line.split(': ')[1]
            elif not line:
                if data:
                    self.sdp = data
                    break
        if self.sdp:
            stream_found = False
            for param in self.sdp:
                if not stream_found and 'm=application' in param:
                    stream_found = True
                elif stream_found and 'a=control:rtsp' in param:
                    self.control_url = param.split(':', 1)[1]
                    break

        if self.status_code == 200:
            if self.state == STATE_STARTING:
                self.sequence += 1
        elif self.status_code == 401:
            # Device requires authorization, do not increment to next method
            pass
        else:
            # If device configuration is correct we should never get here
            _LOGGER.debug(
                "%s RTSP %s %s", self.host, self.status_code, self.status_text)
509829
public boolean updateSessionDetails(final SessionData session) {

        synchronized (sharedLock) {
            if (session != null) {
                SharedPreferences.Editor editor = getSharedPreferences().edit();
                editor.putString(KEY_PROFILE_ID, session.getProfileId());
                editor.putString(KEY_SESSION_ID, session.getSessionId());
                editor.putString(KEY_ACCESS_TOKEN, session.getAccessToken());
                editor.putLong(KEY_EXPIRES_ON, session.getExpiresOn());
                boolean isUpdated = editor.commit();
                sharedLock.notifyAll();
                return isUpdated;
            }
            sharedLock.notifyAll();
        }

        return false;
    }
1027216
def update(self, auth, resource, desc={}, defer=False):
        
        return self._call('update', auth, [resource, desc], defer)
385805
def set_session_info(app, response, **extra):
    """"""
    session_id = getattr(session, 'sid_s', None)
    if session_id:
        response.headers['X-Session-ID'] = session_id
    if current_user.is_authenticated:
        response.headers['X-User-ID'] = current_user.get_id()
350369
def _on_group_stream_changed(self, data):
        """"""
        self._groups.get(data.get('id')).update_stream(data)
239450
def update(self, response, **kwargs):
        '''
        
        '''
        response_cls = super(
            LocationResponseClassLegacyAccessor, self)._get_instance(**kwargs)
        if response_cls:
            setattr(response_cls, self.column, self.accessor(response))
            setattr(
                response_cls, self.venue_column, self.venue_accessor(response))
            _action_and_commit(response_cls, session.add)
1274397
def update_device_list(self, sessions):
        
        if sessions is None:
            _LOGGER.error('Error updating Emby devices.')
            return

        new_devices = []
        active_devices = []
        dev_update = False
        for device in sessions:
            dev_name = '{}.{}'.format(device['DeviceId'], device['Client'])

            try:
                _LOGGER.debug('Session msg on %s of type: %s, themeflag: %s',
                              dev_name, device['NowPlayingItem']['Type'],
                              device['NowPlayingItem']['IsThemeMedia'])
            except KeyError:
                pass

            active_devices.append(dev_name)
            if dev_name not in self._devices and \
                    device['DeviceId'] != str(self._api_id):
                _LOGGER.debug('New Emby DeviceID: %s. Adding to device list.',
                              dev_name)
                new = EmbyDevice(device, self)
                self._devices[dev_name] = new
                new_devices.append(new)
            elif device['DeviceId'] != str(self._api_id):
                # Before we send in new data check for changes to state
                # to decide if we need to fire the update callback
                if not self._devices[dev_name].is_active:
                    # Device wasn't active on the last update
                    # We need to fire a device callback to let subs now
                    dev_update = True

                do_update = self.update_check(
                    self._devices[dev_name], device)
                self._devices[dev_name].update_data(device)
                self._devices[dev_name].set_active(True)
                if dev_update:
                    self._do_new_devices_callback(0)
                    dev_update = False
                if do_update:
                    self._do_update_callback(dev_name)

        # Need to check for new inactive devices and flag
        for dev_id in self._devices:
            if dev_id not in active_devices:
                # Device no longer active
                if self._devices[dev_id].is_active:
                    self._devices[dev_id].set_active(False)
                    self._do_update_callback(dev_id)
                    self._do_stale_devices_callback(dev_id)

        # Call device callback if new devices were found.
        if new_devices:
            self._do_new_devices_callback(0)
992906
def _update_activities(self):
        """"""
        self._activities = self._activities_request()
        _LOGGER.debug("Device Activities Response: %s", self._activities)

        if not self._activities:
            self._activities = []
        elif not isinstance(self._activities, (list, tuple)):
            self._activities = [self._activities]

        self._update_events()
928468
def refresh_session_token(self):
        
        response = client.put('/users/{}/refreshSessionToken'.format(self.id), None)
        content = response.json()
        self._update_data(content)
        self._handle_save_result(False)
1236649
function updateSession(callback) {
  core.api({method: ''}, function(err, response) {
    var session;
    if (err) {
      core.log('error encountered updating session:', err);
      callback && callback(err, null);
      return;
    }

    if (!response.token.valid) {
      // Invalid token. Either it has expired or the user has
      // revoked permission, so clear out our stored data.
      logout(callback);
      return;
    }

    callback && callback(null, session);
  });
}
1007850
def update_room(self, stream_id, room_definition):
        '''  '''
        req_hook = 'pod/v2/room/' + str(stream_id) + '/update'
        req_args = json.dumps(room_definition)
        status_code, response = self.__rest__.POST_query(req_hook, req_args)
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response
1133875
def add_response(self, req, resp):
        
        if self._cache is None:
            return
        signature = sign(req.allocateQuotaRequest)
        with self._cache as c:
            now = self._timer()
            item = c.get(signature)
            if item is None:
                c[signature] = CachedItem(
                    req, resp, self.service_name, now)
            else:
                # Update the cached item to reflect that it is updated
                item.last_check_time = now
                item.response = resp
                item.is_in_flight = False
                c[signature] = item
1303746
def refresh(self):
        
        j = self.vera_request(id='sdata', output_format='json').json()
        devices = j.get('devices')
        for device_data in devices:
            if device_data.get('id') == self.device_id:
                self.update(device_data)
159881
def update_state(self, up_to_timestamp):
        
        for stream_id in self.streams:
            self.streams[stream_id].calculated_intervals = TimeIntervals([(MIN_DATE, up_to_timestamp)])
        self.up_to_timestamp = up_to_timestamp
961496
@ProbeAtEntry
    @ProbeSite(clazz="com.ibm.ws.session.SessionEventDispatcher",method="sessionLiveCountInc",args="java.lang.Object")
    public void IncrementLiveCount(@Args Object[] myargs )
    {                      	
        if(tc.isEntryEnabled()){
            Tr.entry(tc, "IncrementLiveCount");
        }
        if(myargs == null){
            if(tc.isEntryEnabled()){
                Tr.exit(tc, "IncrementLiveCount","Args list is null");
            }
            return;
        }
        ISession session = (ISession) myargs[0];
        
        if(session == null){
            if(tc.isEntryEnabled()){
                Tr.exit(tc,"IncrementLiveCount","session object is null"); 
            }
              return;
        }        
        String appName =  session.getIStore().getId();        
        SessionStats sStats = sessionCountByName.get(appName);        
        if(sStats==null){
            sStats = initializeSessionStats(appName ,new SessionStats() );
        }      
        
        sStats.liveCountInc();    
        if(tc.isEntryEnabled()){
            Tr.exit(tc, "IncrementLiveCount");
        }
    }
518313
def _update_state(self, response):
        
        # Clear trailing states
        self._states = self._states[:self._cursor + 1]

        # Append new state
        state = RoboState(self, response)
        self._states.append(state)
        self._cursor += 1

        # Clear leading states
        if self._maxlen:
            decrement = len(self._states) - self._maxlen
            if decrement > 0:
                self._states = self._states[decrement:]
                self._cursor -= decrement
1272343
def play_next(self, stream_url=None, offset=0, opaque_token=None):
        """"""

        directive = self._play_directive('REPLACE_ENQUEUED')
        directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque_token=opaque_token)
        self._response['directives'].append(directive)
        return self