Ejemplo n.º 1
0
        /// <summary>
        /// Gets an RtmCallManager object.
        /// </summary>
        /// <param name="eventHandler">	An RtmCallEventHandler object.</param>
        /// <returns>An RtmCallManager object.</returns>
        public RtmCallManager GetRtmCallManager(RtmCallEventHandler eventHandler)
        {
            if (_rtmServicePtr == IntPtr.Zero)
            {
                Debug.LogError("rtmService is null");
                return(null);
            }
            if (eventHandler == null)
            {
                Debug.LogError("eventHandler is null");
                return(null);
            }
            IntPtr rtmCallManagerPtr = getRtmCallManager(_rtmServicePtr, eventHandler.GetPtr());

            if (_rtmCallManager == null)
            {
                _rtmCallManager = new RtmCallManager(rtmCallManagerPtr, eventHandler);
            }
            return(_rtmCallManager);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases all resources used by the RtmClient instance.
        /// Note: Do not call this method in any of your callbacks.
        /// </summary>
        /// <param name="sync">
        /// wheather release rtm client async.
        /// </param>
        private void Release(bool sync)
        {
            Debug.Log("RtmClient Release");
            if (_rtmServicePtr == IntPtr.Zero)
            {
                Debug.LogError("rtmServicePtr is null");
                return;
            }

            foreach (KeyValuePair <string, RtmChannel> item in channelDic)
            {
                RtmChannel channel = item.Value;
                if (channel != null)
                {
                    channel.Dispose();
                }
            }
            channelDic.Clear();
            channelDic = null;

            foreach (RtmChannelAttribute item in attributeList)
            {
                if (item != null)
                {
                    item.Dispose();
                }
            }
            attributeList.Clear();
            attributeList = null;

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

            release(_rtmServicePtr, sync);
            _rtmServicePtr = IntPtr.Zero;
            _eventHandler.Release();
            _eventHandler = null;
        }