[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / player/context/SessionHandler

# player/context/SessionHandler

## Interfaces

### ConnectionLaneHandler

Defined in: [packages/prismarine/src/player/context/SessionHandler.ts:14](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/player/context/SessionHandler.ts#L14)

A connection-lane handler: it touches only its own session, and runs when its packet arrives.

#### Extends

- `LaneHandler`\<`P`, [`SessionContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#sessioncontext), `"connection"`, [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)\>

#### Type Parameters

##### P

`P`

#### Properties

##### lane

> `readonly` **lane**: `"connection"`

Defined in: [packages/protocol/src/handler/PacketHandler.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L41)

When the handler runs relative to the world tick.

###### Inherited from

`LaneHandler.lane`

##### phases

> `readonly` **phases**: readonly [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)[]

Defined in: [packages/protocol/src/handler/PacketHandler.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L23)

The session phases in which the packet is accepted. The side drops it in any other.

###### Inherited from

`LaneHandler.phases`

#### Methods

##### handle()

> **handle**(`packet`, `context`): `void` \| `Promise`\<`void`\>

Defined in: [packages/protocol/src/handler/PacketHandler.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L31)

Handles one packet.

###### Parameters

###### packet

`P`

The decoded packet.

###### context

[`SessionContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#sessioncontext)

What the side hands the handler.

###### Returns

`void` \| `Promise`\<`void`\>

###### Inherited from

`LaneHandler.handle`

***

### InputLaneHandler

Defined in: [packages/prismarine/src/player/context/SessionHandler.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/player/context/SessionHandler.ts#L23)

An input-lane handler: applied synchronously in the input step of its sender's world, inside
one unit of that world's change log, so a throw undoes what it wrote.

#### Extends

- `InputHandler`\<`P`, [`InputContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#inputcontext), [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)\>

#### Type Parameters

##### P

`P`

#### Properties

##### lane

> `readonly` **lane**: `"input"`

Defined in: [packages/protocol/src/handler/PacketHandler.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L41)

When the handler runs relative to the world tick.

###### Inherited from

`InputHandler.lane`

##### phases

> `readonly` **phases**: readonly [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)[]

Defined in: [packages/protocol/src/handler/PacketHandler.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L23)

The session phases in which the packet is accepted. The side drops it in any other.

###### Inherited from

`InputHandler.phases`

#### Methods

##### handle()

> **handle**(`packet`, `context`): `undefined`

Defined in: [packages/protocol/src/handler/PacketHandler.ts:60](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L60)

Applies one input.

###### Parameters

###### packet

`P`

The decoded packet.

###### context

[`InputContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#inputcontext)

What the side hands an input-lane handler.

###### Returns

`undefined`

###### Inherited from

`InputHandler.handle`

***

### ReadLaneHandler

Defined in: [packages/prismarine/src/player/context/SessionHandler.ts:17](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/player/context/SessionHandler.ts#L17)

A read-lane handler: it reads the world, writes nothing, and answers only its sender.

#### Extends

- `LaneHandler`\<`P`, [`SessionContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#sessioncontext), `"read"`, [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)\>

#### Type Parameters

##### P

`P`

#### Properties

##### lane

> `readonly` **lane**: `"read"`

Defined in: [packages/protocol/src/handler/PacketHandler.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L41)

When the handler runs relative to the world tick.

###### Inherited from

`LaneHandler.lane`

##### phases

> `readonly` **phases**: readonly [`SessionPhase`](https://jsprismarine.dev/api/@jsprismarine/prismarine/network/SessionPhase/index.md#sessionphase)[]

Defined in: [packages/protocol/src/handler/PacketHandler.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L23)

The session phases in which the packet is accepted. The side drops it in any other.

###### Inherited from

`LaneHandler.phases`

#### Methods

##### handle()

> **handle**(`packet`, `context`): `void` \| `Promise`\<`void`\>

Defined in: [packages/protocol/src/handler/PacketHandler.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/protocol/src/handler/PacketHandler.ts#L31)

Handles one packet.

###### Parameters

###### packet

`P`

The decoded packet.

###### context

[`SessionContext`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/context/HandlerContext/index.md#sessioncontext)

What the side hands the handler.

###### Returns

`void` \| `Promise`\<`void`\>

###### Inherited from

`LaneHandler.handle`

## Type Aliases

### SessionHandler

> **SessionHandler**\<`P`\> = [`ConnectionLaneHandler`](#connectionlanehandler)\<`P`\> \| [`ReadLaneHandler`](#readlanehandler)\<`P`\> \| [`InputLaneHandler`](#inputlanehandler)\<`P`\>

Defined in: [packages/prismarine/src/player/context/SessionHandler.ts:26](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/player/context/SessionHandler.ts#L26)

Any handler of a player session in the shared shape, its context chosen by its lane.

#### Type Parameters

##### P

`P`
