Changeset 244


Ignore:
Timestamp:
07/12/13 16:26:31 (10 years ago)
Author:
bowman
Message:

Added an example of how to deal with contested cw's (obtained from the cache or otherwise).

Location:
trunk/src/com/bowman/cardserv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/bowman/cardserv/session/AbstractSession.java

    r238 r244  
    361361      }
    362362
     363      if(ecmReply.isContested()) {
     364        boolean saved = false;
     365        if(lastTransaction != null) {
     366          CamdNetMessage prevDcw = lastTransaction.getReply();
     367          if(!prevDcw.isEmpty()) {
     368            Set candidates = new HashSet(ecmReply.getCandidates());
     369            CamdNetMessage c;
     370            candidates.add(ecmReply);
     371            // if there are multiple candidates, look for one in sequence with the previously sent (only works for single-user/single-tuner clients)
     372            for(Iterator iter = candidates.iterator(); iter.hasNext(); ) {
     373              c = (CamdNetMessage)iter.next();
     374              if(prevDcw.equalsSingleDcw(c)) {
     375                saved = true;
     376                ecmReply = c;
     377                break;
     378              }
     379            }
     380          }
     381        }
     382        if(saved) {
     383          setFlag(ecmRequest, '!');
     384        } else {
     385          setFlag(ecmRequest, '?');
     386          logger.warning("Client encountered contested cw: " + ecmReply.toDebugString() + " (alternatives: " + ecmReply.getCandidates() + ")");
     387        }
     388      }
     389
    363390      ecmRequest = ((EcmTransaction)transactions.get(ecmRequest)).getRequest(); // make sure original instance is used
    364391      if(ecmRequest.getCommandTag() != ecmReply.getCommandTag()) { // ensure table id is same as it was in request
  • trunk/src/com/bowman/cardserv/web/GHttpBackend.java

    r243 r244  
    343343      } else throw new IOException("Invalid content length (" + content.length + ")");
    344344    } catch (GHttpAuthException e) {
    345       return getErrorResponse(403, "Forbidden");
     345      return e.getResponse();
    346346    } catch (Exception e) {
    347347      parent.logger.throwing("Bad ghttp feeder request: " + req.getQueryString(), e);
Note: See TracChangeset for help on using the changeset viewer.