本文整理汇总了Python中jasmin.vendor.smpp.twisted.protocol.SMPPClientProtocol类的典型用法代码示例。如果您正苦于以下问题:Python SMPPClientProtocol类的具体用法?Python SMPPClientProtocol怎么用?Python SMPPClientProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMPPClientProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionMade
def connectionMade(self):
twistedSMPPClientProtocol.connectionMade(self)
self.factory.stats.set('connected_at', datetime.now())
self.factory.stats.inc('connected_count')
self.log.info("Connection made to %s:%s", self.config().host, self.config().port)
self.factory.connectDeferred.callback(self)
示例2: sendPDU
def sendPDU(self, pdu):
twistedSMPPClientProtocol.sendPDU(self, pdu)
# Stats:
self.factory.stats.set('last_sent_pdu_at', datetime.now())
if pdu.commandId == CommandId.enquire_link:
self.factory.stats.set('last_sent_elink_at', datetime.now())
self.factory.stats.inc('elink_count')
elif pdu.commandId == CommandId.submit_sm:
self.factory.stats.inc('submit_sm_request_count')
示例3: doPDURequest
def doPDURequest(self, reqPDU, handler):
twistedSMPPClientProtocol.doPDURequest(self, reqPDU, handler)
# Stats
if reqPDU.commandId == CommandId.enquire_link:
self.factory.stats.set('last_received_elink_at', datetime.now())
elif reqPDU.commandId == CommandId.deliver_sm:
self.factory.stats.inc('deliver_sm_count')
elif reqPDU.commandId == CommandId.data_sm:
self.factory.stats.inc('data_sm_count')
示例4: getProtocolObject
def getProtocolObject(self):
smpp = SMPPClientProtocol()
config = SMPPClientConfig(
host='localhost',
port = 82,
username = '',
password = '',
)
smpp.config = Mock(return_value=config)
return smpp
示例5: claimSeqNum
def claimSeqNum(self):
seqNum = twistedSMPPClientProtocol.claimSeqNum(self)
self.factory.stats.set('last_seqNum_at', datetime.now())
self.factory.stats.set('last_seqNum', seqNum)
return seqNum
示例6: sendDataRequest
def sendDataRequest(self, pdu):
"""If pdu has a 'vendor_specific_bypass' tag, it will be deleted before sending it
This is a workaround to let Jasmin accepts messages with vendor TLVs but not forwarding them
to upstream connectors.
Related to #325
"""
if pdu.commandId == CommandId.submit_sm and 'vendor_specific_bypass' in pdu.params:
del pdu.params['vendor_specific_bypass']
return twistedSMPPClientProtocol.sendDataRequest(self, pdu)
示例7: cancelOutboundTransactions
def cancelOutboundTransactions(self, error):
"""Cancels LongSubmitSmTransactions when cancelling OutboundTransactions
"""
twistedSMPPClientProtocol.cancelOutboundTransactions(self, error)
self.cancelLongSubmitSmTransactions(error)
示例8: bindAsTransceiver
def bindAsTransceiver(self):
"""This is a different signature where msgHandler is taken from factory
"""
return twistedSMPPClientProtocol.bindAsTransceiver(self, self.factory.msgHandler)
示例9: connectionMade
def connectionMade(self):
twistedSMPPClientProtocol.connectionMade(self)
self.log.info("Connection made to %s:%s" % (self.factory.config.host, self.factory.config.port))
self.factory.connectDeferred.callback(self)
示例10: __init__
def __init__( self ):
twistedSMPPClientProtocol.__init__(self)
self.longSubmitSmTxns = {}
示例11: doSendRequest
def doSendRequest(self, pdu, timeout):
if self.connectionCorrupted:
raise SMPPClientConnectionCorruptedError()
if not isinstance( pdu, PDURequest ) or pdu.requireAck is None:
raise SMPPClientError("Invalid PDU to send: %s" % pdu)
if pdu.commandId == CommandId.submit_sm:
# Start a LongSubmitSmTransaction if pdu is a long submit_sm and send multiple
# pdus, each with an OutboundTransaction
# - Every OutboundTransaction is closed upon receiving the correct submit_sm_resp
# - Every LongSubmitSmTransaction is closed upong closing all included OutboundTransactions
# UDH is set ?
UDHI_INDICATOR_SET = False
if hasattr(pdu.params['esm_class'], 'gsmFeatures'):
for gsmFeature in pdu.params['esm_class'].gsmFeatures:
if str(gsmFeature) == 'UDHI_INDICATOR_SET':
UDHI_INDICATOR_SET = True
# Discover any splitting method, otherwise, it is a single SubmitSm
if 'sar_msg_ref_num' in pdu.params:
splitMethod = 'sar'
elif UDHI_INDICATOR_SET and pdu.params['short_message'][:3] == '\x05\x00\x03':
splitMethod = 'udh'
else:
splitMethod = None
if splitMethod is not None:
partedSmPdu = pdu
first = True
# Iterate through parted PDUs
while True:
partedSmPdu.seqNum = self.claimSeqNum()
# Set LongSubmitSm tracking flags in pdu:
partedSmPdu.LongSubmitSm = {'msg_ref_num': None, 'total_segments': None, 'segment_seqnum': None}
if splitMethod == 'sar':
# Using SAR options:
partedSmPdu.LongSubmitSm['msg_ref_num'] = partedSmPdu.params['sar_msg_ref_num']
partedSmPdu.LongSubmitSm['total_segments'] = partedSmPdu.params['sar_total_segments']
partedSmPdu.LongSubmitSm['segment_seqnum'] = partedSmPdu.params['sar_segment_seqnum']
elif splitMethod == 'udh':
# Using UDH options:
partedSmPdu.LongSubmitSm['msg_ref_num'] = struct.unpack('!B', pdu.params['short_message'][3])[0]
partedSmPdu.LongSubmitSm['total_segments'] = struct.unpack('!B', pdu.params['short_message'][4])[0]
partedSmPdu.LongSubmitSm['segment_seqnum'] = struct.unpack('!B', pdu.params['short_message'][5])[0]
self.preSubmitSm(partedSmPdu)
self.sendPDU(partedSmPdu)
# Not like parent protocol's sendPDU, we don't return per pdu
# deferred, we'll return per transaction deferred instead
self.startOutboundTransaction(partedSmPdu, timeout).addCallbacks(
self.endLongSubmitSmTransaction,
self.endLongSubmitSmTransactionErr
)
# Start a transaction using the first parted PDU
if first:
first = False
txn = self.startLongSubmitSmTransaction(partedSmPdu, timeout)
try:
# There still another PDU to go for
partedSmPdu = partedSmPdu.nextPdu
except AttributeError:
break
return txn
else:
self.preSubmitSm(pdu)
return twistedSMPPClientProtocol.doSendRequest(self, pdu, timeout)
示例12: connectionLost
def connectionLost(self, reason):
twistedSMPPClientProtocol.connectionLost(self, reason)
self.factory.stats.set('disconnected_at', datetime.now())
self.factory.stats.inc('disconnected_count')
示例13: bindSucceeded
def bindSucceeded(self, result, nextState):
self.factory.stats.set('bound_at', datetime.now())
self.factory.stats.inc('bound_count')
return twistedSMPPClientProtocol.bindSucceeded(self, result, nextState)
示例14: enquireLinkTimerExpired
def enquireLinkTimerExpired(self):
twistedSMPPClientProtocol.enquireLinkTimerExpired(self)
self.factory.stats.set('last_sent_elink_at', datetime.now())
示例15: sendPDU
def sendPDU(self, pdu):
twistedSMPPClientProtocol.sendPDU(self, pdu)
self.factory.stats.set('last_sent_pdu_at', datetime.now())