示例#1
0
func readLoop(cli *client.Client, finish *sync.WaitGroup) {

	for i := 0; i < messagesToRead; i++ {
		<-cli.IncomingRelay()
		if showStat {
			allStats.IncomingMessages.Increase(1)
		}
	}

	finish.Done()
}
示例#2
0
func ForwardAndListen(cli *client.Client) int {

	var received int
	req := message.NewRelayRequest(cli.List(), testBody)
	incoming := cli.IncomingRelay()
	var expectedIncoming int = MessagesPerCLient * (ClientsNum - 1)

	for i := 0; i < MessagesPerCLient; i++ {
		go cli.Send(req)
	}

	for i := 0; i < expectedIncoming; i++ {
		select {
		case <-incoming:
			received++
		case <-time.After(TimeoutTime):
			log.Println(cli.Id(), "timed out")
			return received
		}
	}

	return received

}