Ejemplo n.º 1
0
        public override int OnEvent(MsrpEvent e)
        {
            MsrpSession session = e.getSipSession();
            MsrpMessage message = e.getMessage();

            if (session != null && message != null)
            {
                uint id = session.getId();
                //Console.WriteLine("Msrp Event {0} {1}", id, message.getMsrpHeaderValue("Byte-Range"));

                long start, end, total;
                //message.getByteRange(out start, out end, out total);
                //Console.WriteLine("Byte-Range {0}-{1}/{2}", start, end, total);

                //if (message.isRequest())
                // {
                //    uint size = message.getMsrpContentLength();
                //     byte[] bytes = new byte[(int)size];
                //     message.getMsrpContent(bytes, (uint)bytes.Length);
                // }


                if (!message.isRequest() && message.getCode() == 200)
                {
                    if (message.isLastChunck())
                    {
                        session.hangup();
                    }
                }
            }
            return(0);
        }
Ejemplo n.º 2
0
            private void ProcessResponse(MsrpMessage message)
            {
                short code = message.getCode();

                if (code >= 200 && code <= 299)
                {
                    // File Transfer => ProgressBar
                    if (this.session.MediaType == MediaType.FileTransfer)
                    {
                        long start = -1, end = -1, total = -1;
                        message.getByteRange(out start, out end, out total);
                        MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.SUCCESS_2XX);
                        eargs.AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_START, start)
                        .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_END, end)
                        .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_TOTAL, total)
                        .AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code)
                        .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                        EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                    }
                }
                else if (code >= 300)
                {
                    MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.ERROR);
                    eargs.AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code)
                    .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                    EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                }
            }
Ejemplo n.º 3
0
            private void ProcessResponse(MsrpMessage message)
            {
                short code = message.getCode();

                if (code >= 200 && code <= 299)
                {
                    if (this.session.MediaType == MediaType.FileTransfer)
                    {
                        long start = -1L;
                        long end   = -1L;
                        long total = -1L;
                        message.getByteRange(out start, out end, out total);
                        MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.SUCCESS_2XX);
                        eargs.AddExtra("byte-start", start).AddExtra("byte-end", end).AddExtra("byte-total", total).AddExtra("response-code", code).AddExtra("session", this.session);
                        EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.mOnMsrpEvent, this.session, eargs);
                    }
                }
                else if (code >= 300)
                {
                    MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.ERROR);
                    eargs.AddExtra("response-code", code).AddExtra("session", this.session);
                    EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.mOnMsrpEvent, this.session, eargs);
                }
            }