當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Message.Body方法代碼示例

本文整理匯總了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)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:10,代碼來源:pubsub_test.go

示例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)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:17,代碼來源:bus_test.go

示例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
		}
	}
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:23,代碼來源:server.go

示例4: SendHook

func (dt *devTest) SendHook(m *mangos.Message) bool {
	m.Body = append(m.Body, byte(dt.GetSend()))
	return dt.T.SendHook(m)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:4,代碼來源:device_test.go

示例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)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:5,代碼來源:survey_test.go

示例6: SendHook

func (pt *pairTest) SendHook(m *mangos.Message) bool {
	m.Body = append(m.Body, byte(pt.GetSend()))
	return pt.T.SendHook(m)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:4,代碼來源:pair_test.go

示例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)
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:5,代碼來源:reqrep_test.go


注:本文中的github.com/kildevaeld/projects/cmd/Godeps/_workspace/src/github.com/gdamore/mangos.Message.Body方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。