コード例 #1
0
		private void OnIndexingStatus (ResponseMessage r)
		{
			IndexingStatusResponse response = (IndexingStatusResponse) r;

			if (this.IndexingStatusEvent != null)
				this.IndexingStatusEvent (response.Status);
		}
コード例 #2
0
ファイル: Query.cs プロジェクト: zweib730/beagrep
		///////////////////////////////////////////////////////////////

		private void OnHitsAdded (ResponseMessage r)
		{
			HitsAddedResponse response = (HitsAddedResponse) r;

			if (this.HitsAddedEvent != null)
				this.HitsAddedEvent (response);
		}
コード例 #3
0
ファイル: UnixTransport.cs プロジェクト: universsky/beagrep
        public override ResponseMessage Send(RequestMessage request)
        {
            if (request.Keepalive)
            {
                throw new Exception("A blocking connection on a keepalive request is not allowed");
            }

            Exception throw_me = null;

            try {
                SendRequest(request);
            } catch (IOException e) {
                throw_me = e;
            } catch (SocketException e) {
                throw_me = e;
            }

            if (throw_me != null)
            {
                throw new ResponseMessageException(throw_me);
            }

            NetworkStream stream = this.client.GetStream();
            int           bytes_read, end_index = -1;

            do
            {
                bytes_read = stream.Read(this.network_data, 0, 4096);

                //Logger.Log.Debug ("Read {0} bytes", bytes_read);

                if (bytes_read > 0)
                {
                    // 0xff signifies end of message
                    end_index = Array.IndexOf <byte> (this.network_data, (byte)0xff);

                    this.BufferStream.Write(this.network_data, 0,
                                            end_index == -1 ? bytes_read : end_index);
                }
            } while (bytes_read > 0 && end_index == -1);

            // It's possible that the server side shut down the
            // connection before we had a chance to read any data.
            // If this is the case, throw a rather descriptive
            // exception.
            if (this.BufferStream.Length == 0)
            {
                this.BufferStream.Close();
                throw new ResponseMessageException("Socket was closed before any data could be read");
            }

            this.BufferStream.Seek(0, SeekOrigin.Begin);

#if ENABLE_XML_DUMP
            StreamReader dump_reader = new StreamReader(this.BufferStream);
            Logger.Log.Debug("Received response:\n{0}\n", dump_reader.ReadToEnd());
            this.BufferStream.Seek(0, SeekOrigin.Begin);
#endif

            ResponseMessage resp = null;

            try {
                ResponseWrapper wrapper = (ResponseWrapper)resp_serializer.Deserialize(this.BufferStream);
                resp = wrapper.Message;
            } catch (Exception e) {
                this.BufferStream.Seek(0, SeekOrigin.Begin);
                StreamReader r = new StreamReader(this.BufferStream);
                throw_me = new ResponseMessageException(e, "Exception while deserializing response", String.Format("Message contents: '{0}'", r.ReadToEnd()));
                this.BufferStream.Seek(0, SeekOrigin.Begin);
            }

            this.BufferStream.Close();

            if (throw_me != null)
            {
                throw throw_me;
            }

            return(resp);
        }
コード例 #4
0
ファイル: Message.cs プロジェクト: zweib730/beagrep
		public ResponseWrapper (ResponseMessage response)
		{
			this.Message = response;
		}
コード例 #5
0
ファイル: Message.cs プロジェクト: zweib730/beagrep
		protected void SendAsyncResponse (ResponseMessage response)
		{
			if (this.AsyncResponseEvent != null)
				this.AsyncResponseEvent (response);
		}
コード例 #6
0
ファイル: Message.cs プロジェクト: zweib730/beagrep
		private void OnAsyncResponse (ResponseMessage response)
		{
			AsyncResponseHandler async_response = (AsyncResponseHandler) this.handlers [response.GetType ()];

			if (async_response != null) {
				async_response (response);
			}
		}
コード例 #7
0
ファイル: Transport.cs プロジェクト: zweib730/beagrep
			public EventThrowingClosure (Transport transport, ResponseMessage response)
			{
				this.transport = transport;
				this.response = response;
			}
コード例 #8
0
ファイル: Transport.cs プロジェクト: zweib730/beagrep
		protected void InvokeAsyncResponseEvent (ResponseMessage response)
		{
			if (AsyncResponse != null)
				AsyncResponse (response);
		}
コード例 #9
0
ファイル: Query.cs プロジェクト: zweib730/beagrep
		private void OnFinished (ResponseMessage r)
		{
			FinishedResponse response = (FinishedResponse) r;
	
			if (this.FinishedEvent != null)
				this.FinishedEvent (response);
		}
コード例 #10
0
ファイル: Query.cs プロジェクト: zweib730/beagrep
		private void OnSearchTerms (ResponseMessage r)
		{
			SearchTermResponse response = (SearchTermResponse) r;
			ProcessSearchTermResponse (response);
		}
コード例 #11
0
ファイル: Query.cs プロジェクト: zweib730/beagrep
		private void OnError (ResponseMessage r)
		{
			ErrorResponse response = (ErrorResponse) r;
			throw new ResponseMessageException (response);
		}