func main() { fmt.Println("Stress start!") service.Register() myService.Register() center.Use([]string{"Error", "Master", "Harbor", "StressAdd"}) if center.BaseConfig.Master.IsMaster { for { prompt() var i int fmt.Scanf("%d", &i) fmt.Println() switch i { case 1: fmt.Println("show") case 2: center.Send("main", "Master", 0, center.MsgTypeHarbor, &service.RemoteMessage{"StressAdd", center.MsgTypeHarbor, []byte("start")}) case 3: center.Send("main", "Master", 0, center.MsgTypeHarbor, &service.RemoteMessage{"StressAdd", center.MsgTypeHarbor, []byte("stop")}) default: fmt.Println("Unkown operation.") } fmt.Println() } } else { for { time.Sleep(100 * time.Millisecond) } } fmt.Println("Stress exit!") glog.Flush() }
func main() { glog.Info("Claw start!") service.Register() center.Use([]string{"Error", "Master", "Harbor", "Test"}) center.Send("main", "Test", 1, center.MsgTypeText, "hello, test service") center.Send("main", "Error", 1, center.MsgTypeText, "sth. is wrong") for { time.Sleep(100 * time.Millisecond) } glog.Info("Claw exit!") glog.Flush() }
func regReader(session int, reader *bufio.Reader, err error) { if err != nil { glog.Infof("[Event]: %d leave", session) return } packBuf := make([]byte, 512) n, _ := reader.Read(packBuf) msg := packBuf[:n] glog.Infof("%d say: %s", session, string(msg)) center.Send("main", "Gate", 0, center.MsgTypeText, msg) }
func send(source, destination string, session int, msgType int, msg interface{}) { center.Send(source, destination, session, msgType, msg) }