Esempio n. 1
0
        /// <summary>
        /// Deserialize <see cref="RequestInit"/>.
        /// </summary>
        /// <returns>The deserialized request</returns>
        private RequestInit DeserializeRequestInit(ulong uid)
        {
            ulong  sessionId  = this.binaryReader.ReadUInt64();
            string sessionPwd = this.binaryReader.ReadString();
            bool   readonlyInterfaceRequiresLocks = this.binaryReader.ReadBoolean();

            RequestInit.RedirectionPolicy red = (RequestInit.RedirectionPolicy) this.binaryReader.ReadByte();

            return(new RequestInit(sessionId, sessionPwd, readonlyInterfaceRequiresLocks, red, uid));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the connection with the server.
        /// </summary>
        /// <param name="connection">Connection to initialize</param>
        /// <param name="sessionId">Id of the session</param>
        /// <param name="sessionPassword">Session Password</param>
        /// <returns>Task that tracks completion of this method</returns>
        private async Task Init(
            IConnection connection,
            ulong sessionId,
            string sessionPassword)
        {
            RequestInit.RedirectionPolicy redirectionPolicy = this.configuration.MustTransparentlyForwardRequests
                ? RequestInit.RedirectionPolicy.ForwardPreferred
                : RequestInit.RedirectionPolicy.RedirectPreferred;

            var initRequest = new RequestInit(
                sessionId,
                sessionPassword,
                readOnlyInterfaceRequiresLocks: this.configuration.RequireLockForReadOnlyOperations,
                redirection: redirectionPolicy);

            var requestWrapper = this.RegisterRequest(initRequest);

            RingMasterClientEventSource.Log.Init(requestWrapper.CallId, sessionId, sessionPassword);
            await this.SendRequest(connection, requestWrapper);

            RequestResponse response = await requestWrapper.TaskCompletionSource.Task;

            ThrowIfError(response);
        }