本文整理匯總了Python中transport.Transport.process方法的典型用法代碼示例。如果您正苦於以下問題:Python Transport.process方法的具體用法?Python Transport.process怎麽用?Python Transport.process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類transport.Transport
的用法示例。
在下文中一共展示了Transport.process方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Mailgun
# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import process [as 別名]
class Mailgun(object):
def __init__(self, domain, api_key):
self._client = Transport(domain, api_key)
def get(self, action, *args, **kwargs):
"""
HTTP GET method
"""
return self._client.process(action, "get", *args, **kwargs)
def post(self, action, *args, **kwargs):
"""
HTTP POST method
"""
return self._client.process(action, "post", *args, **kwargs)
def delete(self, action, *args, **kwargs):
"""
HTTP DELETE method
"""
return self._client.process(action, "delete", *args, **kwargs)
def put(self, action, *args, **kwargs):
"""
HTTP PUT method
"""
return self._client.process(action, "put", *args, **kwargs)
示例2: __init__
# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import process [as 別名]
class Client:
def __init__(self, user):
self.user = user
self.ip = str(54) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255)) + '.' + str(random.randrange(0, 255))
self.connections = []
self.routerBuffer = []
self.inbox = {}
self.transportLayer = Transport(self)
self.applicationLayer = Application(self)
# Adds a link between this client and another
def addConnection(self, client):
if client == self:
return
if client.ip in self.connections:
return
self.connections.append(client.ip)
# Sends a message (tells the application layer to make a packet)
def sendMessage(self, source, destination, message , time):
applicationPacket = self.applicationLayer.generatePacket(time, source, destination, message)
tcpPackets = self.transportLayer.process(applicationPacket, time)
def __repr__(self):
return self.ip
def __str__(self):
return self.ip + ' - ' + str(self.connections) + " => Router Buffer: " + str(self.routerBuffer) + " Inbox: " + str(self.inbox)