Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the RtmpContext class.
 /// </summary>
 /// <param name="mode"></param>
 public RtmpContext(RtmpMode mode)
 {
     //_mode = mode;
     _readerWriterLock = new FastReaderWriterLock();
     SetMode(mode);
     _objectEncoding = ObjectEncoding.AMF0;
 }
Ejemplo n.º 2
0
 public RtmptConnection(RtmptServer rtmptServer, IPEndPoint ipEndPoint, string path, Hashtable parameters)
     : base(rtmptServer.RtmpHandler, RtmpMode.Server, path, parameters)
 {
     _lock           = new FastReaderWriterLock();
     _remoteEndPoint = ipEndPoint;
     _rtmptServer    = rtmptServer;
     _readBytes      = new AtomicLong();
     _writtenBytes   = new AtomicLong();
     _session        = rtmptServer.Endpoint.GetMessageBroker().SessionManager.CreateSession(this);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectPool&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="capacity">The number of elements that the object pool object initially contains.</param>
 /// <param name="growth">The number of elements reserved in the object pool when there are no available objects.</param>
 /// <param name="forceGCOnGrowth">If set to <c>true</c> forces GC on growth.</param>
 public ObjectPool(int capacity, int growth, bool forceGCOnGrowth)
 {
     _lock     = new FastReaderWriterLock();
     _forceGC  = forceGCOnGrowth;
     _growth   = growth;
     _capacity = capacity;
     if (_forceGC)
     {
         GC.WaitForPendingFinalizers();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the BaseConnection class.
 /// </summary>
 /// <param name="path">Scope path on server.</param>
 /// <param name="connectionId">Connection id.</param>
 /// <param name="parameters">Parameters passed from client.</param>
 internal BaseConnection(string path, string connectionId, IDictionary parameters)
 {
     _readerWriterLock = new FastReaderWriterLock();
     _readMessages     = new AtomicLong();
     _writtenMessages  = new AtomicLong();
     _droppedMessages  = new AtomicLong();
     //V4 GUID should be safe to remove the 4 so we can use the id for rtmpt
     _connectionId   = connectionId;
     _objectEncoding = ObjectEncoding.AMF0;
     _path           = path;
     _parameters     = parameters;
     SetIsClosed(false);
 }
Ejemplo n.º 5
0
        void Dispose(bool disposing)
        {
            if (kiberCacheLock != null)
            {
                if (disposing)
                {
                    Clear();
                }

                kiberCacheLock.Dispose();
                kiberCacheLock = null;
            }
        }
        // <summary>
        // Name of job that is waiting for a valid handshake.
        // </summary>
        //private string _waitForHandshakeJob;

        public RtmpServerConnection(RtmpServer rtmpServer, RtmpNetworkStream stream)
            : base(rtmpServer.RtmpHandler, RtmpMode.Server, null, null)
        {
            _lock       = new FastReaderWriterLock();
            _endpoint   = rtmpServer.Endpoint;
            _readBuffer = ByteBuffer.Allocate(4096);
            _readBuffer.Flip();

            // We start with an anonymous connection without a scope.
            // These parameters will be set during the call of "connect" later.
            _rtmpServer        = rtmpServer;
            _rtmpNetworkStream = stream;
            //_state = RtmpConnectionState.Active;
            SetIsTunneled(false);
            IsTunnelingDetected = false;

            _readBytes    = new AtomicLong();
            _writtenBytes = new AtomicLong();

            //Set the legacy collection flag from the endpoint channel settings
            this.Context.UseLegacyCollection = (_endpoint as RtmpEndpoint).IsLegacyCollection;
            this.Context.UseLegacyThrowable  = (_endpoint as RtmpEndpoint).IsLegacyThrowable;
        }
      void Dispose(bool disposing)
      {
         if(IsStarted)
         {
            if(invalidator != null)
            {
               invalidator.CancelAsync();
               invalidator.DoWork -= new DoWorkEventHandler(invalidatorWatch);
               invalidator.Dispose();
               invalidator = null;
            }

            if(Refresh != null)
            {
               Refresh.Set();
               Refresh.Close();
               Refresh = null;
            }

            int x = Interlocked.Decrement(ref instances);
            Debug.WriteLine("OnMapClose: " + x);

            CancelAsyncTasks();
            IsStarted = false;

            if(Matrix != null)
            {
               Matrix.Dispose();
               Matrix = null;
            }

            if(FailedLoads != null)
            {
               lock(FailedLoads)
               {
                  FailedLoads.Clear();
                  RaiseEmptyTileError = false;
               }
               FailedLoads = null;
            }

            // cancel waiting loaders
            Monitor.Enter(tileLoadQueue);
            try
            {
               Monitor.PulseAll(tileLoadQueue);
               tileDrawingList.Clear();
            }
            finally
            {
               Monitor.Exit(tileLoadQueue);
            }

            lock(GThreadPool)
            {
#if PocketPC
                Debug.WriteLine("waiting until loaders are stopped...");
                while(GThreadPool.Count > 0)
                {
                    var t = GThreadPool[0];

                    if (t.State != ThreadState.Stopped)
                    {
                        var tr = t.Join(1111);

                        Debug.WriteLine(t.Name + ", " + t.State);

                        if (!tr)
                        {
                            continue;
                        }
                        else
                        {
                            GThreadPool.Remove(t);
                        }
                    }
                    else
                    {
                        GThreadPool.Remove(t);
                    }
                }
                Thread.Sleep(1111);
#endif
            }

            if(tileDrawingListLock != null)
            {
               tileDrawingListLock.Dispose();
               tileDrawingListLock = null;
               tileDrawingList = null;
            }

            if(x == 0)
            {
#if DEBUG
               GMaps.Instance.CancelTileCaching();
#endif
               GMaps.Instance.noMapInstances = true;
               GMaps.Instance.WaitForCache.Set();
               if(disposing)
               {
                  GMaps.Instance.MemoryCache.Clear();
               }
            }
         }
      }
Ejemplo n.º 8
0
 internal WriterLock(FastReaderWriterLock lockObj)
 {
     _lockObj = lockObj;
     _lockObj.AcquireWriterLock();
 }
Ejemplo n.º 9
0
 internal WriteLockable(FastReaderWriterLock lockObj)
 {
     _lockObj = lockObj;
 }
Ejemplo n.º 10
0
 public RtmpQueuedWriteStream(System.IO.Stream innerStream)
 {
     _innerStream = innerStream;
     _lock        = new FastReaderWriterLock();
 }
Ejemplo n.º 11
0
        void Dispose(bool disposing)
        {
            if(Lock != null)
             {
            if(disposing)
            {
               ClearAllLevels();
            }

            Levels.Clear();
            Levels = null;

            tmp.Clear();
            tmp = null;

            Lock.Dispose();
            Lock = null;
             }
        }
Ejemplo n.º 12
0
        // <summary>
        // Name of job that is waiting for a valid handshake.
        // </summary>
        //private string _waitForHandshakeJob;
        
        public RtmpServerConnection(RtmpServer rtmpServer, RtmpNetworkStream stream)
            : base(rtmpServer.RtmpHandler, RtmpMode.Server, null, null)
		{
            _lock = new FastReaderWriterLock();
            _endpoint = rtmpServer.Endpoint;
            _readBuffer = ByteBuffer.Allocate(4096);
            _readBuffer.Flip();

			// We start with an anonymous connection without a scope.
			// These parameters will be set during the call of "connect" later.
            _rtmpServer = rtmpServer;
            _rtmpNetworkStream = stream;
            //_state = RtmpConnectionState.Active;
            SetIsTunneled(false);
            IsTunnelingDetected = false;

            _readBytes = new AtomicLong();
            _writtenBytes = new AtomicLong();

            //Set the legacy collection flag from the endpoint channel settings
            this.Context.UseLegacyCollection = (_endpoint as RtmpEndpoint).IsLegacyCollection;
            this.Context.UseLegacyThrowable = (_endpoint as RtmpEndpoint).IsLegacyThrowable;
		}
Ejemplo n.º 13
0
		public RtmptConnection(RtmptServer rtmptServer, IPEndPoint ipEndPoint, string path, Hashtable parameters)
			: base(rtmptServer.RtmpHandler, RtmpMode.Server, path, parameters) {
			_lock = new FastReaderWriterLock();
			_remoteEndPoint = ipEndPoint;
			_rtmptServer = rtmptServer;
			_readBytes = new AtomicLong();
			_writtenBytes = new AtomicLong();
			_session = rtmptServer.Endpoint.GetMessageBroker().SessionManager.CreateSession(this);
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Initializes a new instance of the RtmpContext class.
		/// </summary>
		/// <param name="mode"></param>
		public RtmpContext(RtmpMode mode) {
			//_mode = mode;
			_readerWriterLock = new FastReaderWriterLock();
			SetMode(mode);
			_objectEncoding = ObjectEncoding.AMF0;
		}