Exemplo n.º 1
0
        private void AckPush(SIF_Ack ack,
                             AdkHttpResponse response)
        {
            try {
                //  Set SIF_Ack / SIF_Header fields
                SIF_Header hdr = ack.Header;
                hdr.SIF_Timestamp = DateTime.Now;

                hdr.SIF_MsgId    = SifFormatter.GuidToSifRefID(Guid.NewGuid());
                hdr.SIF_SourceId = this.Zone.Agent.Id;

                ack.LogSend(this.Zone.Log);

                response.ContentType = SifIOFormatter.CONTENTTYPE;
                // TODO: This code may need to change. The ADKHttpResponse should not automatically set the content length
                // and other implementations will not do so.
                SifWriter w = new SifWriter(response.GetResponseStream());
                w.Write(ack);
                w.Flush();
            }
            catch (Exception thr) {
                Console.Out.WriteLine
                    ("HttpProtocolHandler failed to send SIF_Ack for pushed message (zone=" +
                    this.Zone.ZoneId + "): " + thr);
                throw new AdkHttpException
                          (AdkHttpStatusCode.ServerError_500_Internal_Server_Error, thr.Message, thr);
            }
        }
        private void AckPush( SIF_Ack ack,
                              AdkHttpResponse response )
        {
            try {
                //  Set SIF_Ack / SIF_Header fields
                SIF_Header hdr = ack.Header;
                hdr.SIF_Timestamp = DateTime.Now;

                hdr.SIF_MsgId = SifFormatter.GuidToSifRefID( Guid.NewGuid() );
                hdr.SIF_SourceId = this.Zone.Agent.Id;

                ack.LogSend( this.Zone.Log );

                response.ContentType = SifIOFormatter.CONTENTTYPE;
                // TODO: This code may need to change. The ADKHttpResponse should not automatically set the content length
                // and other implementations will not do so.
                SifWriter w = new SifWriter( response.GetResponseStream() );
                w.Write( ack );
                w.Flush();
            }
            catch ( Exception thr ) {
                Console.Out.WriteLine
                    ( "HttpProtocolHandler failed to send SIF_Ack for pushed message (zone=" +
                      this.Zone.ZoneId + "): " + thr );
                throw new AdkHttpException
                    ( AdkHttpStatusCode.ServerError_500_Internal_Server_Error, thr.Message, thr );
            }
        }