Exemplo n.º 1
0
//Return a list of all files contained in the server
func list(listFlag bool) {
	if listFlag == true {
		message := helper.CreateMessage(nil, "List", "")
		connection := getConnection("localhost", "8000")
		helper.EncodeMessage(*message, connection)
		mess := helper.DecodeMessage(connection)
		fmt.Println(string(mess.Content))
		connection.Close()
	}
}
Exemplo n.º 2
0
func download(file string) {
	if containsFile(file) {
		message := helper.CreateMessage(nil, "Download", file)
		connection := getConnection("localhost", "8000")
		helper.EncodeMessage(*message, connection)
		mess := helper.DecodeMessage(connection)
		if mess.FileName == "" {
			fmt.Println("NO file found")
		} else {
			file := fmt.Sprintf("./%s/%s", "clientFiles", mess.FileName)
			helper.WriteFile(file, mess.Content)
		}

		connection.Close()
	}
}
Exemplo n.º 3
0
func handleConn(c net.Conn) {
	defer c.Close()
	message := helper.DecodeMessage(c)
	evalInput(message, c)
}