Пример #1
0
func (pt *pubTest) SendHook(m *mangos.Message) bool {
	if pt.pubidx >= len(publish) {
		pt.Errorf("Nothing left to send! (%d/%d)", pt.pubidx, len(publish))
		return false
	}
	m.Body = append(m.Body, []byte(publish[pt.pubidx])...)
	pt.Debugf("Sending %d, %s", pt.pubidx, string(m.Body))
	pt.pubidx++
	return pt.T.SendHook(m)
}
Пример #2
0
func (bt *busTest) SendHook(m *mangos.Message) bool {
	bt.Lock()
	defer bt.Unlock()
	v := uint32(bt.GetID())
	w := bt.send
	bt.send++
	m.Body = m.Body[0:8]

	binary.BigEndian.PutUint32(m.Body, v)
	binary.BigEndian.PutUint32(m.Body[4:], w)

	// Inject a sleep to avoid overwhelming the bus and dropping messages.
	//d := time.Duration(rand.Uint32() % 10000)
	//time.Sleep(d * time.Microsecond)

	return bt.T.SendHook(m)
}
Пример #3
0
func serverWorker(sock mangos.Socket, id int) {
	var err error

	delay := rand.Intn(int(time.Second))

	for {
		var m *mangos.Message

		if m, err = sock.RecvMsg(); err != nil {
			return
		}

		m.Body = make([]byte, 4)

		time.Sleep(time.Duration(delay))

		binary.BigEndian.PutUint32(m.Body[0:], uint32(id))

		if err = sock.SendMsg(m); err != nil {
			return
		}
	}
}
Пример #4
0
func (dt *devTest) SendHook(m *mangos.Message) bool {
	m.Body = append(m.Body, byte(dt.GetSend()))
	return dt.T.SendHook(m)
}
Пример #5
0
func (st *surveyTest) SendHook(m *mangos.Message) bool {
	m.Body = m.Body[0:4]
	binary.BigEndian.PutUint32(m.Body, uint32(st.GetSend()))
	return st.T.SendHook(m)
}
Пример #6
0
func (pt *pairTest) SendHook(m *mangos.Message) bool {
	m.Body = append(m.Body, byte(pt.GetSend()))
	return pt.T.SendHook(m)
}
Пример #7
0
func (rt *reqTest) SendHook(m *mangos.Message) bool {
	m.Body = append(m.Body, byte(rt.GetSend()))
	rt.tot = rt.GetSend()
	return rt.T.SendHook(m)
}