Esempio n. 1
0
        public MsrpMessage getMessage()
        {
            IntPtr      cPtr = tinyWRAPPINVOKE.MsrpEvent_getMessage(swigCPtr);
            MsrpMessage ret  = (cPtr == IntPtr.Zero) ? null : new MsrpMessage(cPtr, false);

            return(ret);
        }
Esempio n. 2
0
 internal static HandleRef getCPtr(MsrpMessage obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 3
0
 internal static HandleRef getCPtr(MsrpMessage obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Esempio n. 4
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);
                }
            }
Esempio n. 5
0
            private void ProcessRequest(MsrpMessage message)
            {
                tmsrp_request_type_t type = message.getRequestType();

                switch (type)
                {
                    case tmsrp_request_type_t.tmsrp_SEND:
                        {
                            uint clen = message.getMsrpContentLength();
                            uint read = 0;
                            if (clen == 0)
                            {
                                LOG.Info("Empty MSRP message");
                                return;
                            }

                            if (this.tempBuffer == null || this.tempBuffer.Length < clen)
                            {
                                this.tempBuffer = new byte[(int)clen];
                            }

                            read = message.getMsrpContent(this.tempBuffer, (uint)this.tempBuffer.Length);
                            if (message.isFirstChunck())
                            {
                                this.contentType = message.getMsrpHeaderValue("Content-Type");
                                if (!String.IsNullOrEmpty(contentType) && contentType.StartsWith(ContentType.CPIM, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    MediaContentCPIM mediaContent = MediaContent.parse(this.tempBuffer, read);
                                    if (mediaContent != null)
                                    {
                                        this.wContentType = mediaContent.getHeaderValue("Content-Type");
                                        this.tempBuffer = mediaContent.getPayload();
                                        read = (uint)this.tempBuffer.Length;
                                        mediaContent.Dispose(); // Hi GC, I want my memory right now
                                    }
                                }
                            }

                            this.AppenData(this.tempBuffer, read);

                            // 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.DATA);
                                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_REQUEST_TYPE, "SEND")
                                    .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                                EventHandlerTrigger.TriggerEvent<MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                            }

                            if (message.isLastChunck())
                            {
                                if (this.session.MediaType == MediaType.Chat && this.chatStream != null)
                                {
                                    MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.DATA);
                                    eargs.AddExtra(MsrpEventArgs.EXTRA_CONTENT_TYPE, this.contentType)
                                        .AddExtra(MsrpEventArgs.EXTRA_WRAPPED_CONTENT_TYPE, this.wContentType)
                                        .AddExtra(MsrpEventArgs.EXTRA_DATA, this.chatStream.ToArray())
                                        .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                                    EventHandlerTrigger.TriggerEvent<MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                                    this.chatStream.SetLength(0);
                                }
                                else if (this.session.MediaType == MediaType.FileTransfer)
                                {
                                    if (this.session.outFileStream != null)
                                    {
                                        lock (this.session.outFileStream)
                                        {
                                            this.session.outFileStream.Close();
                                            this.session.outFileStream = null;
                                        }
                                    }
                                }
                            }

                            break;
                        }

                    case tmsrp_request_type_t.tmsrp_REPORT:
                        {
                            break;
                        }

                    case tmsrp_request_type_t.tmsrp_NONE:
                    case tmsrp_request_type_t.tmsrp_AUTH:
                    default:
                        break;
                }
            }