Browse Source

Trying to fix get and getdata logic

Jonas Pflanzer 5 years ago
parent
commit
56db6d2fc7
1 changed files with 15 additions and 13 deletions
  1. 15 13
      Client-Server Protocol.md

+ 15 - 13
Client-Server Protocol.md

@@ -205,38 +205,40 @@ Server:
 	"command": "get",
 	"file": string,
 	"accept": bool,
+	"chunks": int,
 	"error": string
 }
 ```
-If `accept` is `true` the connection is valid and the server can start sending the file. Else the get request was rejected and is hereby canceled. `error` should contain an error string if the request was rejected.
+If `accept` is `true` the connection is valid and the server can start sending the file. Else the get request was rejected and is hereby canceled. `error` should contain an error string if the request was rejected. `chunks` is the number of chunks of the file.
 
 #### 2.4.2 getdata - download data
 
-Server:
+Client:
 ```
 {
 	"command": "getdata",
 	"file": string,
-	"data": string,
-	"remaining": int,
-	"cancel": bool,
-	"error": string
+	"chunk": int,
+	"cancel": bool
 }
 ```
-`data` is a base64 string and contains a piece of the file. The server will loop this until the file is completely sent and the client has to send a received message for every chunk.
-`remaining` is a counter how many chunks will follow and the transfer is over after it hits `0`.
-If `cancel` is `true` then the download of the file is canceled and an error message should be in `error`.
+If `cancel` is `true` then cancel the download of the file.
 <br /><br />
-Client:
+Server:
 ```
 {
 	"command": "getdata",
 	"file": string,
-	"recieved": int,
-	"cancel": bool
+	"data": string,
+	"remaining": int,
+	"cancel": bool,
+	"error": string
 }
 ```
-If `cancel` is `true` then cancel the download of the file.
+`data` is a base64 string and contains a piece of the file. The client must request every chunk.
+`remaining` is a counter how many chunks will follow and the transfer is over after it hits `0`.
+If `cancel` is `true` then the download of the file is canceled and an error message should be in `error`.
+
 
 ### TODO