protected virtual void HandleServerError(LiteNetLibMessageHandler messageHandler) { // Error sent from server ServerErrorMessage message = messageHandler.ReadMessage <ServerErrorMessage>(); OnServerError(message); }
/// <summary> /// Override this function to show error message / disconnect /// </summary> /// <param name="message"></param> public virtual void OnServerError(ServerErrorMessage message) { if (message.shouldDisconnect && !IsServer) { StopClient(); } }
public void SendServerError(long connectionId, bool shouldDisconnect, string errorMessage) { if (!IsServer) { return; } LiteNetLibPlayer player = null; if (!Players.TryGetValue(connectionId, out player) || !player.IsReady) { return; } ServerErrorMessage message = new ServerErrorMessage(); message.shouldDisconnect = shouldDisconnect; message.errorMessage = errorMessage; ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, GameMsgTypes.ServerDestroyObject, message); }