Ejemplo n.º 1
0
        /// <summary>
        /// Creates an Agora RTM channel.
        /// If the method call succeeds, the SDK returns an <RtmChannel> instance.
        /// If this method call fails, the SDK returns null.
        /// </summary>
        /// <param name="channelId">
        /// The unique channel name. A channelId cannot be empty, null, or "null". Must be less than 64 bytes in length. Supported characters:
        /// All lowercase English letters: a to z
        /// All uppercase English letters: A to Z
        /// All numeric characters: 0 to 9
        /// </param>
        /// <param name="rtmChannelEventHandler"></param>
        /// <returns>
        /// An <RtmChannel> object: Success. If a channel with the same channelId does not exist, the method returns the created channel instance. If a channel with the same channelId already exists, the method returns the existing channel instance.
        /// </returns>
        public RtmChannel CreateChannel(string channelId, RtmChannelEventHandler rtmChannelEventHandler)
        {
            if (_rtmServicePtr == IntPtr.Zero)
            {
                Debug.LogError("rtmServicePtr is null");
                return(null);
            }

            if (rtmChannelEventHandler == null)
            {
                Debug.LogError("rtmChannelEventHandler is null");
            }

            if (channelDic.ContainsKey(channelId))
            {
                if (channelDic[channelId] != null)
                {
                    return(channelDic[channelId]);
                }
            }

            IntPtr     _rtmChannelPtr = createChannel(_rtmServicePtr, channelId, rtmChannelEventHandler.GetChannelEventHandlerPtr());
            RtmChannel channel        = new RtmChannel(_rtmChannelPtr, rtmChannelEventHandler);

            channelDic.Add(channelId, channel);
            return(channel);
        }
Ejemplo n.º 2
0
 public RtmChannel(IntPtr rtmChannelPtr, RtmChannelEventHandler rtmChannelEventHandler)
 {
     _rtmChannelPtr       = rtmChannelPtr;
     _channelEventHandler = rtmChannelEventHandler;
 }