96 lines
2.3 KiB
Smalltalk
96 lines
2.3 KiB
Smalltalk
"
|
|
(C) 2011 by Holger Hans Peter Freyther
|
|
All Rights Reserved
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
"
|
|
|
|
Object subclass: SIPDialog [
|
|
| from from_tag to to_tag dest_ip dest_port is_client call_id |
|
|
<comment: 'I represent a dialog between two parties'>
|
|
<category: 'SIP-Callagent'>
|
|
|
|
SIPDialog class >> generateTag [
|
|
^ SIPRandomHelper generateTag
|
|
]
|
|
|
|
SIPDialog class >> generateCallId [
|
|
^ SIPRandomHelper generateCallId
|
|
]
|
|
|
|
SIPDialog class >> fromUser: aFrom host: aHost port: aPort [
|
|
<category: 'factory'>
|
|
^ self new
|
|
instVarNamed: #from put: aFrom;
|
|
instVarNamed: #from_tag put: self generateTag;
|
|
instVarNamed: #dest_ip put: aHost;
|
|
instVarNamed: #dest_port put: aPort;
|
|
instVarNamed: #is_client put: true;
|
|
instVarNamed: #call_id put: self generateCallId;
|
|
yourself
|
|
]
|
|
|
|
isClient [
|
|
<category: 'direction'>
|
|
^ is_client
|
|
]
|
|
|
|
from: aFrom [
|
|
<category: 'accessing'>
|
|
from := aFrom
|
|
]
|
|
|
|
fromTag: aTag [
|
|
<category: 'accessing'>
|
|
from_tag := aTag
|
|
]
|
|
|
|
to: aTo [
|
|
<category: 'accessing'>
|
|
to := aTo
|
|
]
|
|
|
|
toTag: aTag [
|
|
<category: 'accessing'>
|
|
]
|
|
|
|
callId [
|
|
^ call_id
|
|
]
|
|
|
|
generateTo [
|
|
<category: 'message'>
|
|
^ to_tag isNil
|
|
ifTrue: ['<%1>' % {to}]
|
|
ifFalse: ['<%1>;tag=%2' % {to. to_tag}]
|
|
]
|
|
|
|
generateFrom [
|
|
<category: 'message'>
|
|
^ from_tag isNil
|
|
ifTrue: ['<%1>' % {from}]
|
|
ifFalse: ['<%1>;tag=%2' % {from. from_tag}]
|
|
]
|
|
|
|
destinationAddress [
|
|
^ is_client
|
|
ifTrue: [to]
|
|
ifFalse: [from]
|
|
]
|
|
|
|
from [
|
|
^ from
|
|
]
|
|
]
|