当前位置: 首页>>代码示例>>Golang>>正文


Golang BuffPool.DeleteService方法代码示例

本文整理汇总了Golang中push-server/buffpool.BuffPool.DeleteService方法的典型用法代码示例。如果您正苦于以下问题:Golang BuffPool.DeleteService方法的具体用法?Golang BuffPool.DeleteService怎么用?Golang BuffPool.DeleteService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在push-server/buffpool.BuffPool的用法示例。


在下文中一共展示了BuffPool.DeleteService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: listenService

func (this *RegisterComponent) listenService(conn *net.Conn, buffPool *buffpool.BuffPool, number uint16, userUuid string) error {
	if buffPool == nil {
		err := errors.New("RegisterComponent listenService Error: buffpool is nil")
		return err
	}
	if conn == nil {
		err := errors.New("RegisterComponent listenService Error: the conn is nil")
		if GetRunWithSnode().Flag {
			this.ServiceOffline(userUuid)
		}

		err = buffPool.DeleteService(number, userUuid)
		if err != nil {
			err = fmt.Errorf("RegisterComponent listenService Error:%v", err)
			return err
		}
		return err
	}
	var dispatcher *DispatcherComponent
	for {
		dispatcher = GetDispatcherComponent()
		if dispatcher != nil {
			break
		} else {
			fmt.Println("RegisterComponent listenService Error: can not get DispatcherCompoennt")
		}
	}
	for {
		message, err := this.readMessage(conn)
		if number == protocol.N_ACCOUNT_SYS {

		}
		if err != nil && err != io.EOF && conn != nil {
			fmt.Println("RegisterComponent listenService Error: read message fail")
			continue
		} else if err != nil && (err == io.EOF|conn == nil) {
			err = errors.New("RegisterComponent listenService Error:the connection is invalid")
			err2 := buffPool.DeleteService(number, userUuid)

			if GetRunWithSnode().Flag {
				this.ServiceOffline(userUuid)
			}

			if err2 != nil {
				err2 = fmt.Errorf("RegisterComponent listenService Error: %v", err)
				fmt.Println(err2.Error())
				return err2
			}
			fmt.Println(err.Error())
			return err
		}

		if message == nil {
			continue
		}
		dispatcher.NPushBack(message, true)
	}
	return nil
}
开发者ID:huayuxian,项目名称:im-server-go,代码行数:59,代码来源:register_component.go

示例2: unregisterService

func (this *UnregisterComponent) unregisterService(buffPool *buffpool.BuffPool, msg *protocol.Message) error {
	if buffPool == nil || msg == nil {
		err := errors.New("UnregisterComponent unregisterService() Error: invalid argument")
		return err
	}
	conn := buffPool.QueryService(msg.Number, msg.UserUuid)
	if conn == nil {
		return nil
	}
	//only remove conn from connPool, but do not disconnect this connection
	err := buffPool.DeleteService(msg.Number, msg.UserUuid)
	if err != nil {
		err = errors.New("UnregisterComponent unregisterService() Error: " + err.Error())
		//send failed response to client
		resp, err2 := protocol.NewMessage(protocol.VERSION, protocol.MT_ERROR, protocol.PT_PUSHSERVER, msg.Token, msg.Number, uint16(0),
			P_UID, msg.UserUuid, msg.DeviceId, nil)
		if err2 != nil {
			err2 = errors.New("UnregisterComponent.unregisterService() Error: " + err2.Error())
			return err2
		}
		err3 := sendResponse(conn, resp)
		if err3 != nil {
			err3 = errors.New("UnregisterComponent.unregisterService() Error: " + err3.Error())
			return err3
		}
		return err
	}

	resp, err := protocol.NewMessage(protocol.VERSION, protocol.MT_UNREGISTER, protocol.PT_PUSHSERVER, msg.Token, msg.Number, uint16(0),
		P_UID, msg.UserUuid, msg.DeviceId, nil)
	if err != nil {
		err = errors.New("UnregisterComponent unregisterService() Error:conn is removed from BuffPool, but can not send response to service" + err.Error())
		return err
	}
	err2 := sendResponse(conn, resp)
	if err2 != nil {
		err2 = errors.New("UnregisterComponent unregisterService() Error: conn is reomved from BuffPool, but failed when send response to service" + err2.Error())
		return err2
	}
	return nil
}
开发者ID:huayuxian,项目名称:im-server-go,代码行数:41,代码来源:unregister_component.go


注:本文中的push-server/buffpool.BuffPool.DeleteService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。