Skip to content

Commit

Permalink
Cleaned up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpitts committed Mar 6, 2017
1 parent 991ab16 commit 0790c86
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 36 deletions.
3 changes: 1 addition & 2 deletions sound/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ def __init__(self,data,user):
def __str__(self):
return self.user+": \""+self.data+"\""
def sendData(self,vGUI):
print "Data has been sent:"
print " ",self
print "Data has been sent: ",self
vGUI.sock.send(str(self))
5 changes: 0 additions & 5 deletions voice/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def main(argv=None):
if argv is None: argv = sys.argv
infoDict = dict()
user_setup_gui = UserSetupGUI(Tk(),infoDict)
#infoDict["socket"] = socket.socket()
sock = socket.socket()
#host = socket.gethostname()
infoDict["host"] = socket.gethostname()
infoDict["port"] = 12345 #should be same on server, I think
sock.connect((infoDict["host"],infoDict["port"]))
Expand All @@ -22,8 +20,5 @@ def main(argv=None):

vGUI = VGUI(Tk(),infoDict,sock)

#print sock.recv(1024)
#sock.close

mainloop()
return 0
5 changes: 0 additions & 5 deletions voice/vGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
from sound.audioRecorder import AudioRecorder
class VGUI:
def __init__(self, master,infoDict,sock):



self.master = master
#self.infoDict = infoDict
self.sock = sock
self.audioRecorder = AudioRecorder(self)
#self.socket = infoDict["socket"]
self.host = infoDict["host"]
self.port = infoDict["port"]
self.firstName = infoDict["firstName"]
Expand Down
6 changes: 0 additions & 6 deletions voiceServer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@

def main(argv=None):
if argv is None: argv = sys.argv
#infoDict = dict()
#server_setup_gui = ServerSetupGUI(Tk(),infoDict)
infoDict = {"port":12345,"socket":socket.socket(),"clients":{}}
infoDict["host"] = socket.gethostname()
#sock = socket.socket()
#host = socket.gethostname()
#port = int(infoDict["port"])
sock = infoDict["socket"]
sock.bind((infoDict["host"],infoDict["port"]))
sock.listen(5)
#clients = {} #Keys should be usernames, values should be infodicts. Append clientSender and clientaddress to infodict.
sGUI = SGUI(Tk(),infoDict,sock) #How am I going to run the main loop if this is here?
return 0

20 changes: 2 additions & 18 deletions voiceServer/sGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@
import thread
class SGUI:
def __init__(self, master,infoDict,sock):

#print "1"

self.master = master
self.port = infoDict["port"]
self.sock =sock
self.host = infoDict["host"]
self.clients = {}
#self.sock = sock
master.title("Intercom Server")
labelText = "The purpose of this is to recieve and echo the messages it recieves.\n\n"
self.label = Label(master, text = labelText)
self.label.pack()
#self.master.after(200,self.checkForData)#Every two seconds, check for new data

thread.start_new_thread(self.checkForClients,())
thread.start_new_thread(self.checkForData,())
#print "yes"
mainloop()
def checkForClients(self):
while (True):
clientSender, clientAddress = self.sock.accept() #I think the code stays on this line until something connects
clientSender, clientAddress = self.sock.accept() #blocks other code
clientInfoString = clientSender.recv(1024)
clientInfo = eval(clientInfoString)
clientInfo["socket"]=clientSender
Expand All @@ -37,20 +31,10 @@ def checkForClients(self):

def checkForData(self):
while (True):
#print "checking"
#print "lenclients: ",len(self.clients)
for client in self.clients.values():
#print "0"
sock = client["socket"]
#socks = [client["socket"] for client in self.clients]
#for sock in socks:
#print "1111111111"
data = sock.recv(1024)
#print "2222222222"
#if not data:
#print "no new data"
if data:
self.receiveData(data)
def receiveData(self, sound):
print "Sound has been received:"
print " ",sound
print "Sound has been received: ",sound

0 comments on commit 0790c86

Please sign in to comment.