deleted moved code

This commit is contained in:
Dave Schuyler 2005-01-28 03:39:13 +00:00
parent d50d46a46e
commit ae2edb6f8a
1 changed files with 0 additions and 180 deletions

View File

@ -64,12 +64,6 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
self.heartbeatStarted = 0
self.lastHeartbeat = 0
#%# if wantOtpServer:
#%# # Top level Interest Manager
#%# self._interestIdAssign = 1
#%# self._interestIdScops = 100;
#%# self._interests = {}
# By default, the ClientRepository is set up to respond to
# datagrams from the CMU Panda LAN server. You can
# reassign this member to change the response behavior
@ -814,180 +808,6 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
else:
self.handleUnexpectedMsgType(msgType, di)
#%#:
if 0 and wantOtpServer:
# interest managment
def addInterest(self, parentId, zoneIdList, description, event=None):
"""
Part of the new otp-server code.
"""
self._interestIdAssign += 1
self._interestIdScops += 1
self._interests[self._interestIdAssign] = [ description ,self._interestIdScops, event , "Active" ]
contextId = self._interestIdAssign
scopeId = self._interestIdScops
self._sendAddInterest(contextId, scopeId, parentId, zoneIdList)
assert self.printInterests()
return contextId
def removeInterest(self, contextId, event=None):
"""
Part of the new otp-server code.
"""
answer = 0
if self._interests.has_key(contextId):
if event is not None:
self._interestIdScops += 1
self._interests[contextId][2] = event
self._interests[contextId][1] = self._interestIdScops
self._sendRemoveInterest(contextId)
del self._interests[contextId]
else:
self._interests[contextId][3] = "PendingDel"
self._interests[contextId][2] = None
self._interests[contextId][1] = 0
self._sendRemoveInterest(contextId)
answer = 1
assert self.printInterests()
return answer
def alterInterest(self, contextId, parentId, zoneIdList, description = None, event=None):
"""
Part of the new otp-server code.
Removes old and adds new..
"""
answer = 0
if self._interests.has_key(contextId):
self._interestIdScops += 1
if description is not None:
self._interests[contextId][0] = description
self._interests[contextId][1] = self._interestIdScops;
self._interests[contextId][2] = event;
self._sendAddInterest(contextId,self._interestIdScops, parentId, zoneIdList)
answer = 1
assert self.printInterests()
else:
self.notify.warning("alterInterest: contextId not found: %s" % (contextId))
return answer
def GetInterestScopeID(self, contextId):
"""
Part of the new otp-server code.
Return a ScopeId Id for an Interest
"""
answer = 0
if self._interests.has_key(contextId):
answer = self._interests[contextId][1];
else:
self.notify.warning("GetInterestScopeID: contextId not found: %s" % (contextId))
return answer
def GetInterestScopeEvent(self, contextId):
"""
Part of the new otp-server code.
Return a ScopeId Id for an Interest
"""
answer = None
if self._interests.has_key(contextId):
answer = self._interests[contextId][2];
else:
self.notify.warning("GetInterestScopeEvent: contextId not found: %s" % (contextId))
return answer
def _PonderRemoveFlaggedInterest(self, handle):
"""
Part of the new otp-server code.
Return a ScopeId Id for an Interest
"""
answer = None
if self._interests.has_key(handle):
if self._interests[handle][3] == "PendingDel":
del self._interests[handle]
if __debug__:
def printInterests(self):
"""
Part of the new otp-server code.
"""
print "*********************** Interest Sets **************"
for i in self._interests.keys():
print "Interest ID:%s, Description=%s Scope=%s Event=%s Mode=%s"%(i, self._interests[i][0],self._interests[i][1],self._interests[i][2],self._interests[i][3])
print "****************************************************"
return 1 # for assert()
def _sendAddInterest(self, contextId, scopeId, parentId, zoneIdList):
"""
Part of the new otp-server code.
contextId is a client-side created number that refers to
a set of interests. The same contextId number doesn't
necessarily have any relationship to the same contextId
on another client.
"""
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint16(contextId)
datagram.addUint32(scopeId)
datagram.addUint32(parentId)
print zoneIdList
if isinstance(zoneIdList,types.ListType):
vzl = list(zoneIdList)
vzl.sort()
PythonUtil.uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
else:
datagram.addUint32(zoneIdList)
self.send(datagram)
def _sendRemoveInterest(self, contextId):
"""
Part of the new otp-server code.
contextId is a client-side created number that refers to
a set of interests. The same contextId number doesn't
necessarily have any relationship to the same contextId
on another client.
"""
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_REMOVE_INTEREST)
datagram.addUint16(contextId)
self.send(datagram)
def handleInterestDoneMessage(self, di):
"""
This handles the interest done messages and may dispatch a
action based on the ID , Context
"""
id = di.getUint16()
scope = di.getUint32()
expect_scope = self.GetInterestScopeID(id)
print "handleInterestDoneMessage--> Received ID:%s Scope:%s"%(id,scope);
if expect_scope == scope:
print "handleInterestDoneMessage--> Scope Match:%s Scope:%s"%(id,scope);
event = self.GetInterestScopeEvent(id)
if event is not None:
print "handleInterestDoneMessage--> Send Event : %s"%(event);
messenger.send(event)
else:
print "handleInterestDoneMessage--> No Event ";
self._PonderRemoveFlaggedInterest(id)
else:
print "handleInterestDoneMessage--> Scope MisMatch :%s :%s"%(expect_scope,scope);
assert self.printInterests()
def sendHeartbeat(self):
datagram = PyDatagram()
# Add message type