예제 #1
0
        public RoleUpdater(RoleType roleType, ObservableCollection <Player> playerList, ServerVersion version)
        {
            this.playerList = playerList;
            switch (roleType)
            {
            case RoleType.WHITELIST:
                regexAdd    = regexWhitelistAdd;
                regexRemove = regexWhitelistRemove;
                break;

            case RoleType.BAN_LIST:
                if (version.CompareTo(new ServerVersion {
                    Version = "1.13"
                }) < 0)
                {
                    regexAdd    = regexBanlistAddOld;
                    regexRemove = regexBanlistRemoveOld;
                }
                else
                {
                    regexAdd     = regexBanlistAddNew;
                    checkForFake = true;
                    regexRemove  = regexBanlistRemoveNew;
                }
                break;

            case RoleType.OP_LIST:
                if (version.CompareTo(new ServerVersion {
                    Version = "1.13"
                }) < 0)
                {
                    regexAdd    = regexOPsAddOld;
                    regexRemove = regexOPsRemoveOld;
                }
                else
                {
                    regexAdd    = regexOPsAddNew;
                    regexRemove = regexOPsRemoveNew;
                }
                break;

            default: return;
            }
        }
예제 #2
0
        /// <summary>
        /// Decodes the response that we got from <see cref="HandleResponse"/>.
        /// </summary>
        private T DecodeResponse <T>(BinaryHeapStream stream, Func <IBinaryStream, T> readFunc,
                                     Func <ClientStatusCode, string, T> errorFunc)
        {
            ClientStatusCode statusCode;

            if (ServerVersion.CompareTo(Ver140) >= 0)
            {
                var flags = (ClientFlags)stream.ReadShort();

                if ((flags & ClientFlags.AffinityTopologyChanged) == ClientFlags.AffinityTopologyChanged)
                {
                    var topVer = new AffinityTopologyVersion(stream.ReadLong(), stream.ReadInt());
                    if (_topVerCallback != null)
                    {
                        _topVerCallback(topVer);
                    }
                }

                statusCode = (flags & ClientFlags.Error) == ClientFlags.Error
                    ? (ClientStatusCode)stream.ReadInt()
                    : ClientStatusCode.Success;
            }
            else
            {
                statusCode = (ClientStatusCode)stream.ReadInt();
            }

            if (statusCode == ClientStatusCode.Success)
            {
                return(readFunc != null?readFunc(stream) : default(T));
            }

            var msg = BinaryUtils.Marshaller.StartUnmarshal(stream).ReadString();

            if (errorFunc != null)
            {
                return(errorFunc(statusCode, msg));
            }

            throw new IgniteClientException(msg, null, statusCode);
        }