1
# Copyright 2005 Divmod, Inc. See LICENSE file for details
3
def stablesort(self, other):
4
return cmp(self.__class__, getattr(other, '__class__', type(other)))
7
def __init__(self, host, port):
12
return hash((self.host, self.port)) + 5
14
def connect(self, protocolFactory):
15
from twisted.internet import reactor
16
return reactor.connectTCP(self.host, self.port, protocolFactory)
19
return '<TCP@%s,%d>' % (self.host, self.port)
21
def __cmp__(self, other):
22
if isinstance(other, TCPEndpoint):
23
return cmp((self.host, self.port),
24
(other.host, other.port))
25
return stablesort(self, other)
29
def __init__(self, service, fromAddress, toAddress, protocolName):
30
self.service = service
31
self.fromAddress = fromAddress
32
self.toAddress = toAddress
33
self.protocolName = protocolName
36
return '<Q2Q from <%s> to <%s> on %r>' % (
37
self.fromAddress, self.toAddress, self.protocolName)
39
def __cmp__(self, other):
40
if isinstance(other, Q2QEndpoint):
41
return cmp((self.fromAddress, self.toAddress, self.protocolName),
42
(other.fromAddress, other.toAddress, other.protocolName))
43
return stablesort(self, other)
46
return hash((self.fromAddress,
48
self.protocolName)) + 7
50
def connect(self, protocolFactory):
51
# from twisted.python.context import get
53
return self.service.connectQ2Q(
54
self.fromAddress, self.toAddress, self.protocolName,