1 Star 0 Fork 4.9K

Lin_bruin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Service.md 8.79 KB
一键复制 编辑 原始数据 按行查看 历史
wenjun 提交于 2020-09-08 10:08 . add OpenHarmony 1.0 baseline

Service

Overview

Related Modules:

Samgr

Description:

Indicates the basic type of a service.

You need to implement the function pointers of Service.

Summary

Data Fields

Variable Name

Description

GetName )(Service *service)

const char *(* 

Obtains the name of a service.

Initialize )(Service *service, Identity identity)

BOOL(* 

Initializes the service.

MessageHandle )(Service *service, Request *request)

BOOL(* 

Processes service messages.

GetTaskConfig )(Service *service)

TaskConfig(* 

Obtains task configurations of a service.

Details

Field Documentation

GetName

const char*(* Service::GetName) ([Service](Service.md) *service)

Description:

Obtains the name of a service.

This function is called by Samgr during service registration and startup. You need to implement this function.

Parameters:

Name

Description

service Indicates the pointer to the service.

Returns:

Returns a constant string no more than 16 bytes if the service name is obtained successfully; returns NULL if the service name fails to be obtained.

GetTaskConfig

[TaskConfig](TaskConfig.md)(* Service::GetTaskConfig) ([Service](Service.md) *service)

Description:

Obtains task configurations of a service.

This function is used to return task configurations. You need to implement this function.

Parameters:

Name

Description

service Indicates the pointer to the service.

Returns:

Returns TaskConfig.

Initialize

BOOL(* Service::Initialize) ([Service](Service.md) *service, [Identity](Identity.md) identity)

Description:

Initializes the service.

After Samgr assigns tasks to a service, the service calls the function in its own tasks. You need to implement this function.

Parameters:

Name

Description

service Indicates the pointer to the service.
identity Indicates the ID allocated by the system to the service. For details, see Identity.

Returns:

Returns TRUE if the initialization is successful; returns FALSE otherwise.

MessageHandle

BOOL(* Service::MessageHandle) ([Service](Service.md) *service, [Request](Request.md) *request)

Description:

Processes service messages.

This function is used to process requests sent by the caller through IUnknown. You need to implement this function.

Parameters:

Name

Description

service Indicates the pointer to the service.
request Indicates the pointer to the request data.

Returns:

Returns TRUE if the message processing is successful; returns FALSE if the processing fails.

1
https://gitee.com/dreaminghell/docs.git
git@gitee.com:dreaminghell/docs.git
dreaminghell
docs
docs
master

搜索帮助