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


Golang BuffPool.GetAllServices方法代碼示例

本文整理匯總了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
}
開發者ID:huayuxian,項目名稱:im-server-go,代碼行數:49,代碼來源:unregister_component.go

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


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