# Class: Service

## ProtoBuf .Reflect. Service

#### new Service(buildernon-null, rootnon-null, name, optionsopt)

Constructs a new Service.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`builder` | ProtoBuf.Builder |  | Builder reference
`root` | ProtoBuf.Reflect.Namespace |  | Root
`name` | string |  | Service name
`options` | Object.<string, *> | <optional> | Options

Source:
  - protobuf.js, line 3969

### Extends

- ProtoBuf.Reflect.Namespace

### Classes

Method
RPCMethod

### Members

#### (non-null) builder :ProtoBuf.Builder

Builder reference.

##### Type:

- ProtoBuf.Builder

Inherited From:
  - ProtoBuf.Reflect.T#builder
Source:
  - protobuf.js, line 1417

#### (non-null) children :Array.<ProtoBuf.Reflect.T>

Children inside the namespace.

##### Type:

- Array.<ProtoBuf.Reflect.T>

Inherited From:
  - ProtoBuf.Reflect.Namespace#children
Source:
  - protobuf.js, line 1512

#### className :string

Fully qualified class name

##### Type:

- string

Overrides:
  - ProtoBuf.Reflect.Namespace#className
Source:
  - protobuf.js, line 1438

#### (nullable) clazz :function

Built runtime service class.

##### Type:

- function

Source:
  - protobuf.js, line 3981

#### name :string

Object name in namespace.

##### Type:

- string

Inherited From:
  - ProtoBuf.Reflect.T#name
Source:
  - protobuf.js, line 1431

#### (non-null) options :Object.<string, *>

Options.

##### Type:

- Object.<string, *>

Inherited From:
  - ProtoBuf.Reflect.Namespace#options
Source:
  - protobuf.js, line 1518

#### (nullable) parent :ProtoBuf.Reflect.T

Parent object.

##### Type:

- ProtoBuf.Reflect.T

Inherited From:
  - ProtoBuf.Reflect.T#parent
Source:
  - protobuf.js, line 1424

#### (non-null) syntax :string

Syntax level (e.g., proto2 or proto3).

##### Type:

- string

Inherited From:
  - ProtoBuf.Reflect.Namespace#syntax
Source:
  - protobuf.js, line 1524

### Methods

#### addChild(child)

Adds a child to the namespace.

##### Parameters:

Name | Type | Description
--- | --- | ---
`child` | ProtoBuf.Reflect.T | Child

Inherited From:
  - ProtoBuf.Reflect.Namespace#addChild
Source:
  - protobuf.js, line 1556

##### Throws:

If the child cannot be added (duplicate)

Type
  Error

#### build(rebuildopt) → {function}

Builds the service and returns the runtime counterpart, which is a fully functional class.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`rebuild` | boolean | <optional> | Whether to rebuild or not

Overrides:
  - ProtoBuf.Reflect.Namespace#build
Source:
  - protobuf.js, line 3998
See:
  - ProtoBuf.Builder.Service

##### Throws:

If the message cannot be built

Type
  Error

##### Returns:

Service class

Type
  function

#### buildOpt() → {Object.<string, *>}

Builds the namespace's '$options' property.

Inherited From:
  - ProtoBuf.Reflect.Namespace#buildOpt
Source:
  - protobuf.js, line 1666

##### Returns:

Type
  Object.<string, *>

#### fqn() → {string}

Returns the fully qualified name of this object.

Inherited From:
  - ProtoBuf.Reflect.T#fqn
Source:
  - protobuf.js, line 1452

##### Returns:

Fully qualified name as of ".PATH.TO.THIS"

Type
  string

#### getChild(nameOrId) → (nullable) {ProtoBuf.Reflect.T}

Gets a child by its name or id.

##### Parameters:

Name | Type | Description
--- | --- | ---
`nameOrId` | string | number | Child name or id

Inherited From:
  - ProtoBuf.Reflect.Namespace#getChild
Source:
  - protobuf.js, line 1576

##### Returns:

The child or null if not found

Type
  ProtoBuf.Reflect.T

#### getChildren(typeopt) → {Array.<ProtoBuf.Reflect.T>}

Returns an array of the namespace's children.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | ProtoBuf.Reflect.T | <optional> | Filter type (returns instances of this type only). Defaults to null (all children).

Inherited From:
  - ProtoBuf.Reflect.Namespace#getChildren
Source:
  - protobuf.js, line 1539

##### Returns:

Type
  Array.<ProtoBuf.Reflect.T>

#### getOption(nameopt) → {*|Object.<string, *>}

Gets the value assigned to the option with the specified name.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string | <optional> | Returns the option value if specified, otherwise all options are returned.

Inherited From:
  - ProtoBuf.Reflect.Namespace#getOption
Source:
  - protobuf.js, line 1687

##### Returns:

null} Option value or NULL if there is no such option

Type
  * | Object.<string, *>

#### qn(tnon-null) → {string}

Determines the shortest qualified name of the specified type, if any, relative to this namespace.

##### Parameters:

Name | Type | Description
--- | --- | ---
`t` | ProtoBuf.Reflect.T | Reflection type

Inherited From:
  - ProtoBuf.Reflect.Namespace#qn
Source:
  - protobuf.js, line 1629

##### Returns:

The shortest qualified name or, if there is none, the fqn

Type
  string

#### resolve(qn, excludeNonNamespaceopt) → (nullable) {ProtoBuf.Reflect.Namespace}

Resolves a reflect object inside of this namespace.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`qn` | string | !Array.<string> |  | Qualified name to resolve
`excludeNonNamespace` | boolean | <optional> | Excludes non-namespace types, defaults to `false`

Inherited From:
  - ProtoBuf.Reflect.Namespace#resolve
Source:
  - protobuf.js, line 1591

##### Returns:

The resolved type or null if not found

Type
  ProtoBuf.Reflect.Namespace

#### toString(includeClassopt)

Returns a string representation of this Reflect object (its fully qualified name).

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`includeClass` | boolean | <optional> | Set to true to include the class name. Defaults to false.

Inherited From:
  - ProtoBuf.Reflect.T#toString
Source:
  - protobuf.js, line 1470

##### Returns:

String representation