Skip to content

Commit

Permalink
Merge pull request tayler6000#22 from tayler6000/bugfix/1.5/Issue-18
Browse files Browse the repository at this point in the history
Fixes tayler6000#18 in 1.5
  • Loading branch information
tayler6000 authored Feb 15, 2022
2 parents 777109f + afa3936 commit 9541ffe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pyVoIP/SIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def parseSIPMessage(self, data):

class SIPClient():
def __init__(self, server, port, username, password, myIP=None, myPort=5060, callCallback=None):
self.NSD = True
self.NSD = False
self.server = server
self.port = port
self.hostname = socket.gethostname()
Expand Down Expand Up @@ -569,6 +569,9 @@ def parseMessage(self, message):
debug("TODO: Add 400 Error on non processable request")

def start(self):
if self.NSD == True:
raise RunTimeError("Attempted to start already started SIPClient")
self.NSD = True
self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#self.out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.s.bind((self.myIP, self.myPort))
Expand Down
8 changes: 6 additions & 2 deletions pyVoIP/VoIP.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ def callback(self, request):
self.sip.out.sendto(ack.encode('utf8'), (self.server, self.port))

def start(self):
self.sip.start()
try:
self.sip.start()
except Exception:
self.sip.stop()
raise

def stop(self):
for x in self.calls.copy():
Expand All @@ -372,4 +376,4 @@ def call(self, number):
request, call_id, sess_id = self.sip.invite(number, medias, pyVoIP.RTP.TransmitType.SENDRECV)
self.calls[call_id] = VoIPCall(self, CallState.DIALING, request, sess_id, self.myIP, ms = medias)

return self.calls[call_id]
return self.calls[call_id]

0 comments on commit 9541ffe

Please sign in to comment.