Beispiel #1
0
        private void HandleSend(HttpRequest request, HttpResponse response)
        {
            RtmptConnection connection = this.GetConnection(request);

            if (connection == null)
            {
                this.HandleBadRequest(__Res.GetString("Rtmpt_UnknownClient", new object[] { this.GetHttpRequestPath(request) }), response);
            }
            else
            {
                if (connection.Client != null)
                {
                    connection.Client.Renew();
                }
                int    contentLength = request.ContentLength;
                byte[] buffer        = new byte[request.InputStream.Length];
                request.InputStream.Read(buffer, 0, (int)request.InputStream.Length);
                ByteBuffer data = ByteBuffer.Wrap(buffer);
                IList      list = connection.Decode(data);
                if ((list == null) || (list.Count == 0))
                {
                    this.ReturnMessage(connection.PollingDelay, response);
                }
                else
                {
                    foreach (object obj2 in list)
                    {
                        try
                        {
                            if (obj2 is ByteBuffer)
                            {
                                ByteBuffer packet = obj2 as ByteBuffer;
                                connection.RawWrite(packet);
                            }
                            else
                            {
                                (FluorineContext.Current as FluorineWebContext).SetConnection(connection);
                                this._rtmpHandler.MessageReceived(connection, obj2);
                            }
                        }
                        catch (Exception exception)
                        {
                            log.Error(__Res.GetString("Rtmp_CouldNotProcessMessage"), exception);
                        }
                    }
                    this.ReturnPendingMessages(connection, response);
                }
            }
        }
Beispiel #2
0
        private void HandleSend(RtmptRequest request)
        {
            RtmptConnection connection = this.GetConnection(request);

            if (connection == null)
            {
                this.HandleBadRequest(__Res.GetString("Rtmpt_UnknownClient", new object[] { request.Url }), request);
            }
            else
            {
                if (connection.Client != null)
                {
                    connection.Client.Renew();
                }
                int        contentLength = request.ContentLength;
                ByteBuffer data          = request.Data;
                IList      list          = connection.Decode(data);
                if ((list == null) || (list.Count == 0))
                {
                    this.ReturnMessage(connection.PollingDelay, request);
                }
                else
                {
                    foreach (object obj2 in list)
                    {
                        try
                        {
                            if (obj2 is ByteBuffer)
                            {
                                ByteBuffer packet = obj2 as ByteBuffer;
                                connection.RawWrite(packet);
                            }
                            else
                            {
                                FluorineRtmpContext.Initialize(connection);
                                this._rtmpHandler.MessageReceived(connection, obj2);
                            }
                        }
                        catch (Exception exception)
                        {
                            log.Error(__Res.GetString("Rtmp_CouldNotProcessMessage"), exception);
                        }
                    }
                    this.ReturnPendingMessages(connection, request);
                }
            }
        }