-
Notifications
You must be signed in to change notification settings - Fork 0
SaB
In this iteration we will finish our server side including establish connection to FireBase, and fixing the last bugs we have. This might be last iteration, we have to finish on time so we will have enough time to the finish report. As well as fixing the running on device bug we have. We need to deal with the important features we need, like deleting files after we send them. Also, we need some data structure to save the file we have on server
Itamar:
- FireBase Intergartion
- Server Functions
Ori:
- Server Functions
- Testing
Handling multi connections
def client_thread(clientsocket, ip, port,serverID , MAX_BUFFER = 4096):
global thread_check_for_internet_exist
global sombodySendToCloud
while True:
#recv file size from client
size = clientsocket.recv(16)
if size.decode('utf8') == "No Change":
print("No Change detected")
break
if not size:
break
size = int(size, 2)
filename = clientsocket.recv(size)
filesize = clientsocket.recv(32)
filesize = int(filesize, 2)
file_to_write = open(filename, 'wb') #creating the recived file on server side
chunksize = 4096
while filesize > 0:
if filesize < chunksize:
chunksize = filesize
data = clientsocket.recv(chunksize)
file_to_write.write(data)
filesize -= len(data)
file_to_write.close()
print('File received successfully from Device')
sendFileToCloud('', serverID, filename`
`def startserver():
serverID = "0001"
os.chdir('Recvied')
serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "127.0.0.1"
port = 5002;
serversock.bind((host,port));
filename = ""
serversock.listen(1);
print ("Waiting for a connection.....")
try:
thread = Thread(target = fileSyncHandlerThread, args=(serverID,))
thread.start()
except:
print("Error trying to create Thread")
#Infinte loop - so the server wont reset after each connetion
while True:
clientsocket,addr = serversock.accept()
ip, port = str(addr[0]), str(addr[1])
print("Got a connection from %s"+ ip + ":" + port)
try:
Thread(target = client_thread , args=(clientsocket, ip, port, serverID)).start()
except:
print("Error trying to create Thread")
serversock.connect(ip, port)
serversock.sendall("Recvied".encode('utf8'))
serversock.close()
`
| Test | Expectation Result | Result |
|---|---|---|
| Handle multi connections | Server know how to respond for more the 1 client | OK |
| Server get files properly | Get files with the new name and the same data | OK |
Project is ready, still few test remain. Next iteration will be some featuring and code reflactoring
Project's Wiki Table of contents
-
Iterations:
- Iteration 0 - ZFR
- Interation 1 - MVP
- Iteration 2 - ASM
- Iteration 3 - SaC
- Iteration 4 - SaB
- Iteration 5 - FH