Protocol version: "0.2"
Every json message must be minimized and be followed by a newline. This rule makes receiving and parsing the messages easier because you can read until a newline comes and you will parse every json message seperately because you won't read multiple json messages from the buffer at a time.
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.
CLI:
{
"command": "connect",
"accept": bool,
"error": string
}
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.
CLI:
{
"command": "version",
"serverversion": string,
"clientversion": string,
"accept": bool
}
If accept
is true
the connection is valid. Else the connection will be terminated after the server answered.
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.
GUI:
write: username
write: password
CLI:
{
"command": "login",
"accept": bool,
"error": string
}
If accept
is true
the connection is valid and the user is logged in. Else error
has an error string and the connection will be terminated after the server answered.
GUI:
write: #ToBeAdded
Server:
{
"command": "signup",
#ToBeAdded
}
If accept
is true
the connection is valid and the user is logged in and signed up. Else error
has an error string and the connection will be terminated after the server answered.
Commands can be sent by the client after a connection has been negotiated (See 1). Commands can be used unrelated to each other.
GUI:
write: "status"
CLI:
{
"command": "status",
"response": string
}
list
to request a list download.
GUI:
write: "list"
CLI:
{
"command": "list",
"accept": bool,
"names": string[],
"error": string
}
Put is split in two commands. put
to request a file upload and putdata
to get the information about an ongoing upload.
GUI:
write: "put" file_path
CLI:
{
"command": "put",
"accept": bool,
"file": string,
"error": string
}
If accept
is true
the connection is valid and the client can start sending the file. Else the put request was rejected and is hereby canceled. error
should contain an error string if the request was rejected.
CLI:
{
"command": "putdata",
"file": string,
"speed": float,
"cancel": bool,
"error": string
}
If cancel
is true
then the upload of the file is canceled and an error message should be in error
.
speed
shall contain a float describing the upload speed in kB/s.
Get is split in two commands. get
to request a file download and getdata
to get the information about an ongoing download.
GUI:
write: "get" file_path
CLI:
{
"command": "get",
"accept": bool,
"file": string,
"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.
CLI:
{
"command": "getdata",
"file": string,
"speed": float,
"cancel": bool,
"error": string
}
If cancel
is true
then the download of the file is canceled and an error message should be in error
.
speed
shall contain a float describing the download speed in kB/s.
Requests the deletion of a file from the server.
GUI:
write: "deletefile" file_name
CLI:
{
"command": "deletefile",
"file": string,
"accept": bool,
"error": string
}
If accept
is true
the command is valid and the server has deleted the file. Else the request was rejected no changes have been made. error
should contain an error string in that case.
GUI:
{
write: "disconnect"
}
CLI:
{
"command": "disconnect",
"accept": bool
}
If accept
is true, the connection is closed and the program can exit.