smalltalk
/
osmo-st-sip
Archived
1
0
Fork 0

misc: Use String>>#expandMacrosWith.. for the random helpers

These generate random strings so it is difficult to unit test. But
the invocation worked:

st> Osmo.SIPRandomHelper generateTag
'MzU0MjIxMTQ1OTIzODI1ODc3NjU_'
st> Osmo.SIPRandomHelper generateCallId
'MTk3MTU3OTAxOA__@xiaoyu'
st> Osmo.SIPUserAgent generateBranch
'z9hG4bKMzU0MjIwNDM2Myw0MjIxNg__'
This commit is contained in:
Holger Hans Peter Freyther 2013-03-31 19:37:51 +02:00
parent 06285b7135
commit 2e1967c49b
2 changed files with 5 additions and 4 deletions

View File

@ -169,7 +169,8 @@ Object subclass: SIPUserAgentBase [
SIPUserAgentBase class >> generateBranch [
| data |
data := '%1,%2' % {DateTime now asUTC asSeconds. Random between: 0 and: 99999}.
data := '<1p>,<2p>' expandMacrosWithArguments:
{DateTime now asUTC asSeconds. Random between: 0 and: 99999}.
^ self branchStart, (SIPBase64 encode: data).
]

View File

@ -65,12 +65,12 @@ Object subclass: SIPRandomHelper [
SIPRandomHelper class >> generateTag [
<category: 'random'>
^ SIPBase64 encode: '%1%2' % {
DateTime now asSeconds. SIPURandom nextInt}
^ SIPBase64 encode: ('<1p><2p' expandMacrosWithArguments:
{DateTime now asSeconds. SIPURandom nextInt})
]
SIPRandomHelper class >> generateCallId [
^ '%1@%2' % {
^ '<1s>@<2s>' expandMacrosWithArguments: {
SIPBase64 encode: SIPURandom nextInt asString.
Sockets.SocketAddress localHostName.}
]