當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。