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

callagent: Fix generating the MGCP message

This commit is contained in:
Holger Hans Peter Freyther 2011-06-10 12:26:10 +02:00
parent 1be7aad6c4
commit 74e2cb0415
1 changed files with 28 additions and 11 deletions

View File

@ -17,7 +17,7 @@
"
Object subclass: MGCPCommand [
| verb transaction endp params sdp|
| verb transaction endp params |
<comment: 'I am a command send to a MGCP gateway. I know my timeout
and such. Each MGCPGateWay can have a MGCPCommand subclass to specify
certain things. E.g. the endpoint numbering is different'>
@ -33,7 +33,7 @@ Object subclass: MGCPCommand [
transactionId: aTransId;
endpoint: (self endpointNumberToName: anEndpoint);
parameterAdd: 'M: recvonly';
parameterAdd: 'C: ', aCallId;
parameterAdd: 'C: ', aCallId asString;
yourself
]
@ -46,11 +46,6 @@ Object subclass: MGCPCommand [
^ hex, '@mgw'
]
initialize [
sdp := OrderedCollection new.
params := OrderedCollection new.
]
verb: aVerb [
<category: 'private'>
verb := aVerb.
@ -66,12 +61,34 @@ Object subclass: MGCPCommand [
transaction := anId.
]
parameterAdd: aParam [
<category: 'private'>
self params add: aParam.
]
params [
<category: 'private'>
^ params ifNil: [params := OrderedCollection new]
]
asDatagram [
| end msg |
| out |
<category: 'networking'>
end := Character lf asString, Character nl asString.
msg := verb, ' ', endp, ' MGCP 1.0', end
out := WriteStream on: (String new).
"write the header"
out
nextPutAll: '%1 %2 %3 MGCP 1.0' % {verb. transaction. endp};
cr; nl.
"write the parameters"
params do: [:each |
out
nextPutAll: each;
cr; nl.
].
^ out contents
]
]