当前位置: 首页>>代码示例>>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;未经允许,请勿转载。