Beispiel #1
0
func StartUP() {
	count := 1

	m := mandela.Manager{}
	m.Run()
	running := true
	reader := bufio.NewReader(os.Stdin)

	// time.Sleep(time.S)
	m.SaveData("tao", "hongfei")

	for running {
		data, _, _ := reader.ReadLine()
		commands := strings.Split(string(data), " ")
		switch commands[0] {
		case "help":

		case "q":
			running = false
		case "info":

		case "send":
			if len(commands) == 1 {
				m.SendMsgForAll("hello " + strconv.Itoa(count))
				count += 1
			}
			if len(commands) == 3 {
				m.SendMsgForOne(commands[1], commands[2])
			}

		case "see":
			if len(commands) == 1 {
				m.See()
			}
			if len(commands) == 2 {
				if commands[1] == "left" {
					m.SeeLeftNode()
				}
				if commands[1] == "right" {
					m.SeeRightNode()
				}
			}
		case "odp":
		case "cdp":
		case "dump":
		}
	}
}
Beispiel #2
0
func StartUP() {
	m := mandela.Manager{}
	m.IsRoot = true

	//---------------------------------------
	//  手动设置端口
	//---------------------------------------
	m.HostPort = 9990

	m.Run()
	running := true
	reader := bufio.NewReader(os.Stdin)

	for running {
		data, _, _ := reader.ReadLine()
		commands := strings.Split(string(data), " ")
		switch commands[0] {
		case "help":

		case "q":
			running = false
		case "info":

		case "send":
		case "see":
			if len(commands) == 1 {
				m.See()
			}
			if len(commands) == 2 {
				if commands[1] == "left" {
					m.SeeLeftNode()
				}
				if commands[1] == "right" {
					m.SeeRightNode()
				}
			}
		case "cap":
		case "odp":
		case "cdp":
		case "dump":
		}
	}
}