Skip to content

Commit

Permalink
Changed default parameter checking and added some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-o committed Jul 22, 2014
1 parent c765ed1 commit e72e7e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ python-libsmpp

SMPP library for Python. Forked from [google code](https://code.google.com/p/smpplib/).


Example:
```python
import logging
Expand Down Expand Up @@ -53,5 +52,15 @@ t = Thread(target=client.listen)
t.start()
```

The client supports setting a custom generator that produces sequence numbers for the PDU packages. Per default a simple in memory generator is used which in conclusion is reset on (re)instantiation of the client, e.g. by an application restart. If you want to keep the sequence number to be persisted across restarts you can implement your own storage backed generator.

Example:
```
import smpplib.client
import mymodule
generator = mymodule.PersistentSequenceGenerator()
client = smpplib.client.Client('example.com', SOMEPORTNUMBER, sequence_generator=generator)
...
```
4 changes: 3 additions & 1 deletion smpplib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def __init__(self, host, port, timeout=5, sequence_generator=None):
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.settimeout(timeout)
self.receiver_mode = False
self.sequence_generator = sequence_generator or SimpleSequenceGenerator()
if sequence_generator is None:
sequence_generator = SimpleSequenceGenerator()
self.sequence_generator = sequence_generator

def __del__(self):
"""Disconnect when client object is destroyed"""
Expand Down

0 comments on commit e72e7e0

Please sign in to comment.