Example #1
0
func mainclient() {
	fmt.Println("starting client...")
	gonet.ClientInit()
	var msg = gonet.Message{Addr: "127.0.0.1:1256", Content: "haha"}
	gonet.Send(msg, nil)
	// time.Sleep(time.Second * 20)
	var input string
	for {
		fmt.Scanln(&input)
		fmt.Println("done")
		msg = gonet.Message{Addr: "127.0.0.1:1256", Content: input}
		gonet.Send(msg, nil)
	}
}
Example #2
0
func sendNode(content string, userCollect func(msg string)) {
	node := <-nodeChan
	log.Printf("send msg to node:%s with message: %s\n", node.Config["NodeAddr"], content)
	msg := gonet.Message{node.Config["NodeAddr"], content}
	gonet.Send(msg, userCollect)
	nodeChan <- node
}
Example #3
0
/*
	call by client
	to send the reduce command to client
*/
func CollectReduceToClient() {
	for _, config := range NodeConfig {
		tempMap := make(map[string]string)
		tempMap["result"] = ReduceMap
		command := &gocommand.Command{"reduce", "reduce", tempMap}
		temp := gocommand.EnCode(command.GetCommandString())
		msg := gonet.Message{config.Config["NodeAddr"], temp}
		gonet.Send(msg, func(msg string) {})
	}
}
Example #4
0
func TestClient(t *testing.T) {
	fmt.Println("starting client...")
	gonet.ClientInit()
	var msg = gonet.Message{Addr: "127.0.0.1:1256", Content: "haha"}
	fmt.Println("runging")
	for {
		fmt.Println("runging")
		gonet.Send(msg)
		time.Sleep(time.Second * 5)
	}
}