本文整理汇总了Golang中push-server/protocol.Message.Number方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Number方法的具体用法?Golang Message.Number怎么用?Golang Message.Number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类push-server/protocol.Message
的用法示例。
在下文中一共展示了Message.Number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Dispatch2
func (this *CacheComponent2) Dispatch2(msg *protocol.Message, flag bool) {
cached := uint16(1 << 15)
if (msg.Number & cached) != cached {
return
}
msg.Number &= HEAD_RESET
msg, err := this.MakeCacheMessage(msg)
if err != nil {
fmt.Println("CacheCompoennt Dispatch2 Error:" + err.Error())
return
}
data1, err := msg.Encode()
if err != nil {
fmt.Println("CacheCompoennt Dispatch2 Error:", err)
return
}
data2 := make([]byte, len(data1)+8)
copy(data2[:8], msg.Data[0:8])
copy(data2[8:], data1)
snode_component.GetNodeComponent().Forward(stree_define.ADD_CACHE_ENTRY, msg.DestUuid, msg.DeviceId, data2)
//if this message is a contact sync message, send it to root first.
if (msg.Number == protocol.N_ACCOUNT_SYS || msg.DeviceId == 0) && flag {
snode_component.GetNodeComponent().Forward(stree_define.BROADCAST_TO_CLIENT, msg.DestUuid, msg.DeviceId, data1)
} else {
GetDispatcherOutComponent().NPushBack(msg, flag)
}
return
}
示例2: Save
func (this *CacheComponent) Save(msg protocol.Message) error {
this.CacheLock.Lock()
defer this.CacheLock.Unlock()
if this.Cache == nil {
this.Cache = make(map[string]CacheDev, 0)
}
if _, ok := this.Cache[msg.DestUuid]; !ok {
val := CacheDev{
MDev: make(map[uint32]*CacheList, 0),
}
this.Cache[msg.DestUuid] = val
}
if _, ok := this.Cache[msg.DestUuid].MDev[msg.DeviceId]; !ok {
val := &CacheList{
List: list.New(),
Total: 0,
}
this.Cache[msg.DestUuid].MDev[msg.DeviceId] = val
}
this.Cache[msg.DestUuid].MDev[msg.DeviceId].Total++
id := this.Cache[msg.DestUuid].MDev[msg.DeviceId].Total
msg.DataLen = 4 + msg.DataLen
buf := make([]byte, msg.DataLen)
binary.BigEndian.PutUint32(buf[0:4], id)
if len(msg.Data) > 0 {
copy(buf[4:msg.DataLen], msg.Data)
}
msg.Data = buf
msg.MsgType = protocol.MT_PUSH_WITH_RESPONSE
msg.PushType = protocol.PT_PUSHSERVER
msg.Number &= HEAD_RESET
e := this.Cache[msg.DestUuid].MDev[msg.DeviceId].List.PushBack(CacheEntry{msg, id})
if e == nil {
err := errors.New("CacheComponent.Save() Error: can not save msg to list")
fmt.Println(err.Error())
return err
}
return nil
}