()
| 42 | } |
| 43 | |
| 44 | func client() { |
| 45 | |
| 46 | queue := cellnet.NewEventQueue() |
| 47 | |
| 48 | p := peer.NewGenericPeer("tcp.Connector", "client", "127.0.0.1:7701", queue) |
| 49 | |
| 50 | rv := proc.NewSyncReceiver(p) |
| 51 | |
| 52 | proc.BindProcessorHandler(p, "tcp.ltv", rv.EventCallback()) |
| 53 | |
| 54 | p.Start() |
| 55 | |
| 56 | queue.StartLoop() |
| 57 | |
| 58 | rv.WaitMessage("cellnet.SessionConnected") |
| 59 | |
| 60 | p.(cellnet.TCPConnector).Session().Send(&TestEchoACK{ |
| 61 | Msg: "hello", |
| 62 | Value: 1234, |
| 63 | }) |
| 64 | |
| 65 | begin := time.Now() |
| 66 | |
| 67 | var lastcheck time.Time |
| 68 | |
| 69 | const total = 10 * time.Second |
| 70 | |
| 71 | for { |
| 72 | |
| 73 | now := time.Now() |
| 74 | |
| 75 | if now.Sub(begin) >= total { |
| 76 | break |
| 77 | } |
| 78 | |
| 79 | if now.Sub(lastcheck) >= time.Second { |
| 80 | fmt.Printf("progress: %d%%\n", now.Sub(begin)*100/total) |
| 81 | lastcheck = now |
| 82 | } |
| 83 | |
| 84 | rv.Recv(func(ev cellnet.Event) { |
| 85 | |
| 86 | ev.Session().Send(&TestEchoACK{ |
| 87 | Msg: "hello", |
| 88 | Value: 1234, |
| 89 | }) |
| 90 | |
| 91 | }) |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |
| 96 | var profile = flag.String("profile", "", "write cpu profile to file") |
| 97 |
no test coverage detected