示例#1
0
        protected virtual void HandleServerError(LiteNetLibMessageHandler messageHandler)
        {
            // Error sent from server
            ServerErrorMessage message = messageHandler.ReadMessage <ServerErrorMessage>();

            OnServerError(message);
        }
示例#2
0
 /// <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();
     }
 }
示例#3
0
        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);
        }