PUN Classic (v1), PUN 2, Bolt는 휴업 모드입니다. Unity2022에 대해서는 PUN 2에서 서포트하지만, 신기능의 추가는 없습니다. 현재 이용중인 고객님의 PUN 및 Bolt 프로젝트는 중단되지 않고, 퍼포먼스나 성능이 떨어지는 일도 없습니다. 앞으로의 새로운 프로젝트에는 Photon Fusion 또는 Quantum을 사용해 주십시오.

Accepting and Refusing Connections

Bolt allows you to accept or refuse an incoming connection attempt early, before a full connection has been made and before the client even starts loading the scene. Normally all connections are accepted automatically, unless you go into Bolt Settings and change Accept Mode to manual (see the figure below). An example use case would be to refuse incoming connections because the server is full.

![Setup Accept Mode](/docs/img/Bolt-Wiki/bolt_accept_mode.png)
Setup Accept Mode.

Clients can send tokens to the server when connecting (e.g. for entering a password protected game session, third party session tickets, etc). This token is passed to ConnectionRequest (see below) and further along in the handshake available as a member of BoltConnection (ConnectToken) available from callbacks like Connected.

On the Client you can use one of the versions of BoltNetwork.Connect to send a request to the Server, trying to connect to it:

public static void BoltNetwork.Connect(UdpSession session, IProtocolToken token);
public static void BoltNetwork.Connect(UdpSession session);
public static void BoltNetwork.Connect(UdpEndPoint endpoint, IProtocolToken token);
public static void BoltNetwork.Connect(UdpEndPoint endpoint);

After you call the Connect method, the following callback will signal that this peer is attempting to connect to the server:

public virtual void GlobalEventListenerBase.ConnectAttempt(UdpEndPoint endpoint, IProtocolToken token);

On the Server, you will receive the following request when a new player tries to connect:

public virtual void GlobalEventListenerBase.ConnectRequest(UdpEndPoint endpoint, IProtocolToken token);

Clients can pass tokens when they connect to the server. This token is used for both ConnectionRequest and Connected on the server.

If your Accept Mode is manual, you must either call:

public static void BoltNetwork.Accept(UdpEndPoint endpoint);
public static void BoltNetwork.Accept(UdpEndPoint endpoint, IProtocolToken acceptToken);


public static void BoltNetwork.Refuse(UdpEndPoint endpoint);
public static void BoltNetwork.Refuse(UdpEndPoint endpoint, IProtocolToken refuseToken);

These methods allow you to return a token if you wish - use this for a response for the client, such as an error message result that you can convert into text for displaying to the user.

The client will receive the following callback if their connection was accepted:

public virtual void GlobalEventListenerBase.Connected(BoltConnection connection);

Or this one, if the connection was refused:

public virtual void GlobalEventListenerBase.ConnectRefused(UdpEndPoint endpoint, IProtocolToken token);

The client can retrieve the Accept token with BoltConnection.AcceptToken inside the Connected callback. The sequence diagram below summarises the overall process:

![Accept-Refuse Flow](/docs/img/Bolt-Wiki/accept_refuse_flow.png)
Accept-Refuse Flow.

기술 문서 TOP으로 돌아가기