Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ClientScene.SendReconnectMessage

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static method SendReconnectMessage(extraMessage: Networking.MessageBase): bool;
public static bool SendReconnectMessage(Networking.MessageBase extraMessage);

Parameters

extraMessageAny extra data to send.

Returns

bool Returns true if the send succeeded.

Description

Send a reconnect message to the new host, used during host migration.

An example usage might be that if you decide to spawn your own player and not use the built in "Auto Create Player" property in the NetworkManager together with HostMigration, you would need to send a reconnect message when your client reconnects. The code below illustrates such an example were we OnClientConnect check if we where disconnected from the host and in that case we send the reconnect message.

no example available in JavaScript
using UnityEngine;
using UnityEngine.Networking;

public class NetworkManagerEx : NetworkManager { public override void OnClientConnect(NetworkConnection conn) { base.OnClientConnect(conn);

if (migrationManager.disconnectedFromHost) { ClientScene.SendReconnectMessage(null); } } }

Did you find this page useful? Please give it a rating: