本文整理匯總了Golang中push-server/buffpool.BuffPool.GetAllServices方法的典型用法代碼示例。如果您正苦於以下問題:Golang BuffPool.GetAllServices方法的具體用法?Golang BuffPool.GetAllServices怎麽用?Golang BuffPool.GetAllServices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類push-server/buffpool.BuffPool
的用法示例。
在下文中一共展示了BuffPool.GetAllServices方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: offlineBroadcast
func (this *UnregisterComponent) offlineBroadcast(buffPool *buffpool.BuffPool, userUuid string, devID uint32) error {
if GetRunWithSnode().Flag {
snode_component.GetNodeComponent().Logout(userID, devID)
snode_component.GetNodeComponent().DecUsersNumber()
snode_component.GetNodeComponent().DecConnNumber()
}
if buffPool == nil {
err := errors.New("UnRegisterComponent offlineBroadcast Error: invalid argument")
return err
}
var dispatcherOut *DispatcherOutComponent
for {
dispatcherOut = GetDispatcherOutComponent()
if dispatcherOut != nil {
break
} else {
fmt.Println("UnregisterComponent.offlineBroadcast() Error:can not get a dispatcher, will try again")
}
}
brMsg := protocol.BRMsg{
UserUuid: userUuid,
DeviceId: devID,
}
brData, err := brMsg.Encode()
if err != nil {
err := errors.New("UnregisterComponent.offlienBroadcast() Error: " + err.Error())
return err
}
servNoUuidArr := buffPool.GetAllServices()
for num, uuidArr := range servNoUuidArr {
for _, uuid := range uuidArr {
offlineMsg, err := protocol.NewMessage(protocol.VERSION, protocol.MT_BROADCAST_OFFLINE, protocol.PT_PUSHSERVER, 0, num, uint16(len(brData)),
P_UID, uuid, 0, brData)
if err != nil {
err = errors.New("UnregisterComponent offlineBroadcast() Error: " + err.Error())
return err
}
dispatcherOut.NPushBack(offlineMsg, false) //not need forward
}
}
return nil
}
示例2: onlineBroadcast
func (this *RegisterComponent) onlineBroadcast(buffPool *buffpool.BuffPool, dispatcherOut *DispatcherOutComponent, userUuid string, deviceID uint32) error {
if GetRunWithSnode().Flag {
onlineInfo := structure.ClientOnlineInfo{
PushID: this.PushID,
ParentID: this.PushID,
}
data, err := onlineInfo.Encode()
if err != nil {
err = errors.New("RegisterComponent onlineBroadcast() Error: " + err.Error())
return err
}
snode_component.GetNodeComponent().Forward(define.ONLINE, userUuid, deviceID, data)
snode_component.GetNodeComponent().AddUsersNumber()
snode_component.GetNodeComponent().AddConnNumber()
}
if buffPool == nil || dispatcherOut == nil {
err := errors.New("RegisterComponent onlineBroadcast() Error: invalid argument")
return err
}
brMsg := protocol.BRMsg{
userUuid,
deviceID,
}
brData, err := brMsg.Encode()
if err != nil {
err := errors.New("RegisterCompoent onlineBroadcast() Error: " + err.Error())
return err
}
servNoUuidArr := buffPool.GetAllServices()
for num, uuidArr := range servNoUuidArr {
for _, uuid := range uuidArr {
onlineMsg, err := protocol.NewMessage(protocol.VERSION, protocol.MT_BROADCAST_ONLINE, protocol.PT_PUSHSERVER, 0, num, uint16(len(brData)),
P_UID, uuid, 0, brData)
if err != nil {
err = errors.New("RegisterComponent onlineBroadcast() Error: " + err.Error())
return err
}
dispatcherOut.NPushBack(onlineMsg, false) //not need forward
}
}
return nil
}