---
title: "setConnectionState(_:completionHandler:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gkgamesession/setconnectionstate(_:completionhandler:)"
---

# setConnectionState(_:completionHandler:)

Sets the connection state for the player.

## Declaration

```swift
func setConnectionState(_ state: GKConnectionState, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func setConnectionState(_ state: GKConnectionState) async throws
```

## Parameters

- `state`: The GKConnectionState to be assigned to the player.
- `completionHandler`: A block that is called after the connect state has been set.

## Discussion

Discussion This method will fail when the game session’s player limit has already been reached or there are network problems. The game session’s lastModifiedDate and lastModifiedPlayer properties are updated on completion.

## See Also

### Connecting Players for Real-Time Communication

- [players(with:)](gamekit/gkgamesession/players(with:).md)
- [send(_:with:completionHandler:)](gamekit/gkgamesession/send(_:with:completionhandler:).md)
- [GKTransportType](gamekit/gktransporttype.md)
