How To Change A Connected Server Without Authentication

UDP client may change its connection to a different server without changing SID and encryption keys.

Using migrate to change the connected server is useful when you need to change the server because you received OnOffline event etc.

The example below shows how to execute migrate.

NOTE: Migrate method raises OnConnect if successful. If not successful OnResponse will be raised and for connection failure, OnException will be raised.

// This is to capture successful migration to another server
diarkisUdpClient.OnConnect += (bool reconnected) =>
{
// reconnecting should be true when migration was successful
if (reconnected)
{
/* Do something amazing */
}
}

// This is to capture migration failure
diarkisUdpClient.OnResponse += (uint ver, uint cmd, uint status, byte[] payload) =>
{
// This is the response of migration
if (ver == (uint)0 && cmd == (uint)2)
{
// This means migration has failed
if (status != diarkisUdpClient.STATUS_OK)
{
/* Handle error here */
}
}
}

// This is to execute server migration
diarkisUdpClient.Migrate();

Migrate To A Specific Server Type

Diarkis server has server types and each server may be assigned a custom server type.

Migration can target a specific server type to have the client migrate.

NOTE: If an invalid server type or a server type that does not exist has been given, migration will fail.

string serverType = "MY_AMAZING_UDP_SERVER";
diarkisUdpClient.Migrate(serverType);