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


Golang BuffPool.GetService方法代碼示例

本文整理匯總了Golang中push-server/buffpool.BuffPool.GetService方法的典型用法代碼示例。如果您正苦於以下問題:Golang BuffPool.GetService方法的具體用法?Golang BuffPool.GetService怎麽用?Golang BuffPool.GetService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在push-server/buffpool.BuffPool的用法示例。


在下文中一共展示了BuffPool.GetService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: sendToService

func (this *DispatcherOutComponent) sendToService(msg *protocol.Message, buffPool *buffpool.BuffPool) (*net.Conn, error) {
	if msg == nil || buffPool == nil {
		err := errors.New("DispatcherOutComponent.sendToService() Error: invalid argument")
		fmt.Println(err.Error())
		return nil, err
	}
	var conn *net.Conn
	if msg.DestUuid == P_UID {
		conn = buffPool.GetService(msg.Number)
	} else {
		conn = buffPool.QueryService(msg.Number, msg.DestUuid)
		if conn == nil {
			conn = buffPool.GetService(msg.Number)
		}
	}

	if conn == nil {
		err := errors.New("DispatcherOutComponent.sendToService() Error:  can not get a server connection from buffpool")
		fmt.Println(err.Error())
		return nil, err
	}

	err := this.sendMessage(msg, conn)
	if err != nil {
		err = errors.New("DispatcherOutComponent.sendToService() Error:  can not send message to server's connection")
		fmt.Println(err.Error())
		return conn, err
	}
	return conn, nil
}
開發者ID:huayuxian,項目名稱:im-server-go,代碼行數:30,代碼來源:dispatcher_out_component.go

示例2: checkAccountServer

func (this *RegisterComponent) checkAccountServer(buffPool *buffpool.BuffPool, message *protocol.Message, conn *net.Conn) bool {
	if buffPool == nil || message == nil || conn == nil {
		fmt.Println("RegisterComponent checkAccountServer() Error: invalid argument")
		return false
	}
	connService := buffPool.GetService(protocol.N_ACCOUNT_SYS)
	if connService == nil {
		fmt.Println("RegisterComponent checkAccountServer() Error: can not get the account_sys server")
		response, _ := protocol.NewMessage(protocol.VERSION, protoocl.MT_ERROR, protocol.PT_PUSHSERVER, message.Token, message.Number, 0, P_UID,
			message.UserUuid, 0, nil)
		err := sendResponse(conn, response)
		if err != nil {
			err = fmt.Errorf("RegisterComponent checkAccountServer() Error:%v", err)
			fmt.Println(err.Error())
		}
		return false
	}
	return true
}
開發者ID:huayuxian,項目名稱:im-server-go,代碼行數:19,代碼來源:register_component.go

示例3: sendToService2

func (this *DispatcherOutComponent) sendToService2(msg *protocol.Message, forward bool, buffPool *buffpool.BuffPool) (*net.Conn, error) {
	if msg == nil || buffPool == nil {
		err := errors.New("DispatcherOutComponent.sendToService() Error: invalid argument")
		fmt.Println(err.Error())
		return nil, err
	}
	var conn *net.Conn
	if msg.DestUuid == P_UID {
		conn = buffPool.GetService(msg.Number)
	} else {
		conn = buffPool.QueryService(msg.Number, msg.DestUuid)
		if conn == nil && forward && GetRunWithSnode().Flag {
			buf, err := msg.Encode()
			if err != nil {
				fmt.Println(err)
				return nil, err
			}
			snode_component.GetNodeComponent().Forward(stree_define.FORWARD, msg.DestUuid, msg.DeviceId, buf)
			return nil, nil
		}
	}

	if conn == nil {
		err := errors.New("DispatcherOutComponent.sendToService() Error:  can not find dest server")
		fmt.Println(err.Error())
		return nil, err
	}

	err := this.sendMessage(msg, conn)
	if err != nil {
		err = errors.New("DispatcherOutComponent.sendToService() Error: can not send message to server's connection")
		fmt.Println(err.Error())
		return conn, err
	}
	if msg.MsgType == protocol.MT_PUBLISH {
		fmt.Println("\n", time.Now().String(), "MT_PUBLISH: sendToService2 Directly OK", "\n")
	}
	return conn, nil
}
開發者ID:huayuxian,項目名稱:im-server-go,代碼行數:39,代碼來源:dispatcher_out_component.go


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