本文整理汇总了Golang中github.com/kildevaeld/projects/Godeps/_workspace/src/github.com/gdamore/mangos.Message.Body方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Body方法的具体用法?Golang Message.Body怎么用?Golang Message.Body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kildevaeld/projects/Godeps/_workspace/src/github.com/gdamore/mangos.Message
的用法示例。
在下文中一共展示了Message.Body方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SendHook
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: SendHook
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: serverWorker
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: SendHook
func (pt *PushTest) SendHook(m *mangos.Message) bool {
m.Body = append(m.Body, byte(pt.GetSend()))
return pt.T.SendHook(m)
}
示例5: SendHook
func (dt *devTest) SendHook(m *mangos.Message) bool {
m.Body = append(m.Body, byte(dt.GetSend()))
return dt.T.SendHook(m)
}
示例6: SendHook
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)
}
示例7: SendHook
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)
}