本文整理匯總了Golang中github.com/kildevaeld/projects/cmd/Godeps/_workspace/src/github.com/gdamore/mangos.Message.Body方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Body方法的具體用法?Golang Message.Body怎麽用?Golang Message.Body使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kildevaeld/projects/cmd/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 (dt *devTest) SendHook(m *mangos.Message) bool {
m.Body = append(m.Body, byte(dt.GetSend()))
return dt.T.SendHook(m)
}
示例5: 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)
}
示例6: SendHook
func (pt *pairTest) SendHook(m *mangos.Message) bool {
m.Body = append(m.Body, byte(pt.GetSend()))
return pt.T.SendHook(m)
}
示例7: 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)
}