Browse Source

added multisession to CLI-GUI protocol

Denys 4 years ago
parent
commit
af331735d5
1 changed files with 44 additions and 14 deletions
  1. 44 14
      GUI-CLI Protocol.md

+ 44 - 14
GUI-CLI Protocol.md

@@ -6,7 +6,20 @@ Every json message must be minimized and be followed by a newline. This rule mak
 
 ## 0. Connect to the server
 
-The GUI creates a new instance of the CLI with the entered IP Address as a paramater. The CLI then tries to establish a connection to the given server and tells the GUI if the connection was successful.
+The GUI creates a new instance of the CLI. Then the GUI sends a connect command to connect to a server. 
+
+## 1. Start a connection
+
+### 1.1 Connecting and version check
+
+The CLI then tries to establish a connection to the given server and tells the GUI if the connection was successful.
+
+GUI:
+```
+write: "connect <ip address> <port>"
+```
+Alternatively, it is possible to only pass an ip address, then by default port 1234 is used.
+
 
 CLI:
 ```
@@ -17,11 +30,8 @@ CLI:
 }
 ```
 
-## 1. Start a connection
-
 To connect to a server, the CLI has to do a version check. Once that is successful, the GUI will pass the username and password to establish a connection.
 
-### 1.1 Version check
 CLI:
 ```
 {
@@ -32,18 +42,17 @@ CLI:
 }
 ```
 
-If `accept` is `true` the connection is valid. Else the connection will be terminated after the server answered.
+If `accept` is `true` the connection is valid. Else the connection will be terminated after the server answered. In this case it it possible to connect again (possibly to another server).
 
 
 ## 1.2 Login / Signup
 
-The GUI will send the username and password right after another into the pipe. If the response contains a "true" for accept, the login was successful.
+The GUI will send a login or signup request into the pipe. If the response contains a "true" for accept, the login was successful.
 
 ### 1.2.1 Login
 GUI:
 ```
-	write: username
-	write: password
+write: "login" username password
 ```
 
 CLI:
@@ -60,14 +69,15 @@ If `accept` is `true` the connection is valid and the user is logged in. Else `e
 ### 1.2.2 Signup
 GUI:
 ```
-	write: #ToBeAdded
+write: "signup" username new_password
 ```
 
 Server:
 ```
 {
-	"command": "signup",
-	#ToBeAdded
+	"command": "login",
+	"accept": bool,
+	"error": string
 }
 ```
 
@@ -105,7 +115,7 @@ CLI:
 ```
 {
 	"command": "list",
-  "accept": bool,
+	"accept": bool,
 	"names": string[],
 	"error": string
 }
@@ -211,15 +221,35 @@ If `accept` is `true` the command is valid and the server has deleted the file.
 ### TODO
 
 
-## 3. Disconnect
+## 3. Disconnecting and exiting
+
+### 3.1. Disconnect
 
 GUI:
 ```
+write: "disconnect"
+```
+
+CLI:
+```
 {
-	write: "disconnect"
+	"command": "disconnect",
+	"accept": bool
 }
 ```
 
+If `accept` is true, the connection is closed and it is possible to connect to another server.
+
+
+### 3.2. Exit
+
+GUI:
+```
+write: "exit"
+```
+
+If the CLI is not connected, the program can exit directly. Otherwise, the CLI sends a disconnect reply first: 
+
 CLI:
 ```
 {