コード例 #1
0
        public static WindowsUnsubscribeRequest CreateAndRead(string domain, BinaryReader requestReader)
        {
            WindowsUnsubscribeRequest request = new WindowsUnsubscribeRequest();

            request.ReadInternal(domain, requestReader);
            return(request);
        }
コード例 #2
0
        public static BinaryRequest Read(BinaryReader requestReader)
        {
            byte version = BinaryHelper.ReadByte(requestReader);

            if (version != BinaryRequest.Version)
            {
                throw new CorrespondenceException(String.Format("This distributor cannot read version {0} requests.", version));
            }

            string domain = BinaryHelper.ReadString(requestReader);

            byte token = BinaryHelper.ReadByte(requestReader);

            if (token == GetManyRequest.Token)
            {
                return(GetManyRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == PostResponse.Token)
            {
                return(PostRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == WindowsSubscribeRequest.Token)
            {
                return(WindowsSubscribeRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == WindowsUnsubscribeRequest.Token)
            {
                return(WindowsUnsubscribeRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == InterruptRequest.Token)
            {
                return(InterruptRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == NotifyRequest.Token)
            {
                return(NotifyRequest.CreateAndRead(domain, requestReader));
            }
            else
            {
                throw new CorrespondenceException(String.Format("Unknown token {0}.", token));
            }
        }