" (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 . " Object subclass: SIPSessionBase [ | rem ua identity initial_dialog dialog next_cseq | SIPSessionBase class >> on: aDialog useragent: aUseragent identity: anIdentity [ ^ self new useragent: aUseragent; identity: anIdentity; initialDialog: aDialog; yourself ] SIPSessionBase class >> on: aDialog useragent: aUseragent [ ^self on: aDialog useragent: aUseragent identity: aUseragent mainIdentity ] initialDialog: aDialog [ initial_dialog := aDialog. initial_dialog contact: ('sip:<1s>@<2p>:<3p>' expandMacrosWith: identity username with: ua transport address with: ua transport port). ] useragent: aUseragent [ ua := aUseragent ] identity: anIdentity [ identity := anIdentity ] callId [ ^ initial_dialog callId ] check: aDialog [ "I check if this enters a new confirmed dialog or if this is the confirmed dialog." "We have no confirmed dialog, accept it" ^ dialog isNil ifTrue: [ aDialog isConfirmed ifTrue: [ dialog := aDialog. self registerDialog. self logNotice: ('SIPCall(<1s>) dialog is confirmed now.' expandMacrosWith: self callId) area: #sip. ]. true] ifFalse: [ "We could fork things here. For multi party call" dialog to_tag = aDialog to_tag]. ] registerDialog [ ua registerDialog: self. ] unregisterDialog [ rem isNil ifTrue: [ rem := Osmo.TimerScheduler instance scheduleInSeconds: 60 block: [ ua unregisterDialog: self. ]] ] nextCSeq [ | res | res := next_cseq. next_cseq := next_cseq + 1. ^ res ] isCompatible: aDialog [ ^ dialog isNil ifTrue: [initial_dialog isCompatible: aDialog] ifFalse: [dialog isCompatible: aDialog]. ] newRequest: aRequest dialog: aDialog [ self logError: ('<1p>(<2s>) unhandled request <3p>.' expandMacrosWithArguments: {self class. self callId. aRequest class verb}) area: #sip. ] ]