本文整理汇总了Golang中github.com/kildevaeld/projects/Godeps/_workspace/src/github.com/gdamore/mangos.Endpoint.RecvMsg方法的典型用法代码示例。如果您正苦于以下问题:Golang Endpoint.RecvMsg方法的具体用法?Golang Endpoint.RecvMsg怎么用?Golang Endpoint.RecvMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kildevaeld/projects/Godeps/_workspace/src/github.com/gdamore/mangos.Endpoint
的用法示例。
在下文中一共展示了Endpoint.RecvMsg方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: receiver
func (r *req) receiver(ep mangos.Endpoint) {
rq := r.sock.RecvChannel()
cq := r.sock.CloseChannel()
for {
m := ep.RecvMsg()
if m == nil {
break
}
if len(m.Body) < 4 {
m.Free()
continue
}
m.Header = append(m.Header, m.Body[:4]...)
m.Body = m.Body[4:]
select {
case rq <- m:
case <-cq:
m.Free()
break
}
}
}
示例2: receiver
func (x *pull) receiver(ep mangos.Endpoint) {
rq := x.sock.RecvChannel()
cq := x.sock.CloseChannel()
for {
m := ep.RecvMsg()
if m == nil {
return
}
select {
case rq <- m:
case <-cq:
return
}
}
}
示例3: receiver
func (r *rep) receiver(ep mangos.Endpoint) {
rq := r.sock.RecvChannel()
cq := r.sock.CloseChannel()
for {
m := ep.RecvMsg()
if m == nil {
return
}
v := ep.GetID()
m.Header = append(m.Header,
byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
hops := 0
// Move backtrace from body to header.
for {
if hops >= r.ttl {
m.Free() // ErrTooManyHops
return
}
hops++
if len(m.Body) < 4 {
m.Free() // ErrGarbled
return
}
m.Header = append(m.Header, m.Body[:4]...)
m.Body = m.Body[4:]
// Check for high order bit set (0x80000000, big endian)
if m.Header[len(m.Header)-4]&0x80 != 0 {
break
}
}
select {
case rq <- m:
case <-cq:
m.Free()
return
}
}
}
示例4: receiver
func (x *resp) receiver(ep mangos.Endpoint) {
rq := x.sock.RecvChannel()
cq := x.sock.CloseChannel()
for {
m := ep.RecvMsg()
if m == nil {
return
}
v := ep.GetID()
m.Header = append(m.Header,
byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
hops := 0
for {
if hops >= x.ttl {
m.Free() // ErrTooManyHops
return
}
hops++
if len(m.Body) < 4 {
m.Free()
continue
}
m.Header = append(m.Header, m.Body[:4]...)
m.Body = m.Body[4:]
if m.Header[len(m.Header)-4]&0x80 != 0 {
break
}
}
select {
case rq <- m:
case <-cq:
m.Free()
return
}
}
}
示例5: receiver
func (s *sub) receiver(ep mangos.Endpoint) {
rq := s.sock.RecvChannel()
cq := s.sock.CloseChannel()
for {
var matched = false
m := ep.RecvMsg()
if m == nil {
return
}
s.Lock()
for _, sub := range s.subs {
if bytes.HasPrefix(m.Body, sub) {
// Matched, send it up. Best effort.
matched = true
break
}
}
s.Unlock()
if !matched {
m.Free()
continue
}
select {
case rq <- m:
case <-cq:
m.Free()
return
default: // no room, drop it
m.Free()
}
}
}