Beispiel #1
0
        public static void ChannelMemberCountCallback(IntPtr channelMemberCounts, int count)
        {
            UnityMainThreadDispatcher.Instance().Enqueue(() =>
            {
                Debug.Log("channel member count callback: " + count);
                if (count > 0)
                {
                    var cmc      = new ChannelMemberCount[count];
                    int typeSize = Marshal.SizeOf(typeof(ChannelMemberCount));
                    Debug.Log("before for");
                    for (int i = 0; i < count; i++)
                    {
                        cmc[i] = (ChannelMemberCount)Marshal.PtrToStructure(new IntPtr(channelMemberCounts.ToInt64() + (i * typeSize)), typeof(ChannelMemberCount));
                        Debug.Log("after marshal");
                    }

                    RtmWrapper.Instance.OnChannelMemberCountReceivedCallback(0, cmc.ToList());
                    RtmWrapperDll.freeChannelMemberCount(channelMemberCounts, cmc.Length);
                }
                else
                {
                    Debug.Log("Query Peers: No results!");
                }
            });
        }
Beispiel #2
0
 protected override void LogoutAndReleaseRtmService()
 {
     if (LoggedIn)
     {
         LoggedIn = false;
         RtmWrapperDll.logout();
         RtmWrapperDll.release();
     }
 }
Beispiel #3
0
        public override void SendPeerMessage(string peerId, string msg, bool enableOffline)
        {
            if (string.IsNullOrEmpty(peerId))
            {
                Debug.LogError("You need to enter the user ID you want to send the message to");
                return;
            }

            Debug.Log("send peer msg: " + msg);
            RtmWrapperDll.sendMessageToPeer(peerId, msg, enableOffline ? 1 : 0);
        }
Beispiel #4
0
        protected override void CreateRtmServiceAndLogin(string appId, string token, string username)
        {
            if (LoggedIn)
            {
                return;
            }

            RtmWrapperDll.init(appId, onConnectionStateChanged, onMessageReceived, onPeersOnlineStatusChanged, onRtmKitTokenDidExpire);
            Debug.Log(RtmWrapperDll.getSDKVersion());
            Debug.Log("token: " + token + " || username: " + username);
            RtmWrapperDll.loginByToken(token, username, onLogin);
        }
Beispiel #5
0
        protected IRtmChannel CreateAndJoinChannel(string channelName, Action <object> successCallback)
        {
            var chHandle = RtmWrapperDll.createChannelWithId(channelName,
                                                             onMemberJoined, onMemberLeft, onChannelMessageReceived, onMemberCount);

            var channel = new RtmChannelIOS(channelName, chHandle, successCallback);

            curChannel = channel;
            channel.Join();

            return(channel);
        }
Beispiel #6
0
        public override IRtmChannel JoinChannel(string channelName)
        {
            channelMessageCallback = new RtmWrapperDll.ChannelMessageReceivedHandler(ChannelMessageHandler);
            leaveCallback          = new RtmWrapperDll.LeaveHandler(LeaveChannelHandler);
            getMembersCallback     = new RtmWrapperDll.GetMembersHandler(GetChannelMembersHandler);

            var channel = RtmWrapperDll.createChannel(channelName,
                                                      (mid, status) => { Debug.Log("message " + mid + " sent with status: " + status); },
                                                      () => { UnityMainThreadDispatcher.Instance().Enqueue(() => { channels.Add(channelName); Debug.Log("joined: " + channelName);  OnJoinSuccessCallback(); }); },
                                                      (errorCode) => { Debug.Log("error joining channel: " + errorCode); },
                                                      channelMessageCallback,
                                                      leaveCallback,
                                                      getMembersCallback
                                                      );

            channel.Join();

            return(channel);
        }
        public override IRtmChannel JoinChannel(string channelName)
        {
            channelMessageCallback = new RtmWrapperDll.ChannelMessageReceivedHandler(ChannelMessageHandler);
            leaveCallback          = new RtmWrapperDll.LeaveHandler(LeaveChannelHandler);
            getMembersCallback     = new RtmWrapperDll.GetMembersHandler(GetChannelMembersHandler);

            var channel = RtmWrapperDll.createChannel(channelName,
                                                      (mid, status) => { },
                                                      () => {
                channels.Add(channelName);
                OnJoinSuccessCallback();
            },
                                                      (errorCode) => { },
                                                      channelMessageCallback,
                                                      leaveCallback,
                                                      getMembersCallback
                                                      );

            channel.Join();

            return(channel);
        }
Beispiel #8
0
        protected override void CreateRtmServiceAndLogin(string appId, string token, string username)
        {
            if (LoggedIn)
            {
                return;
            }

            loginCallback           = new RtmWrapperDll.LoginSuccessHandler(LoginHandler);
            peerMessageCallback     = new RtmWrapperDll.PeerMessageReceivedHandler(PeerMessageHandler);
            queryUserStatusCallback = new RtmWrapperDll.QueryStatusReceivedHandler(QueryUserStatusHandler);
            memberCountCallback     = new RtmWrapperDll.GetChannelMembersCountHandler(ChannelMemberCountHandler);

            Debug.Log("create rtm service: " + RtmWrapperDll.createRtmService(appId,
                                                                              (In64, state) => { Debug.Log("STATE: " + state); },
                                                                              peerMessageCallback,
                                                                              loginCallback,
                                                                              (errCode) => { Debug.Log("Error: " + errCode); },
                                                                              queryUserStatusCallback,
                                                                              null,
                                                                              memberCountCallback
                                                                              ));

            Debug.Log("login: " + RtmWrapperDll.login(token, username));
        }
        protected override void CreateRtmServiceAndLogin(string appId, string token, string username)
        {
            if (LoggedIn)
            {
                return;
            }

            loginCallback           = new RtmWrapperDll.LoginSuccessHandler(LoginHandler);
            peerMessageCallback     = new RtmWrapperDll.PeerMessageReceivedHandler(PeerMessageHandler);
            queryUserStatusCallback = new RtmWrapperDll.QueryStatusReceivedHandler(QueryUserStatusHandler);
            memberCountCallback     = new RtmWrapperDll.GetChannelMembersCountHandler(ChannelMemberCountHandler);
            byte[] appidbytes = System.Text.Encoding.ASCII.GetBytes(appId);
            RtmWrapperDll.createRtmServiceInstance(appId,
                                                   null,
                                                   peerMessageCallback,
                                                   loginCallback,
                                                   null,
                                                   queryUserStatusCallback,
                                                   null,
                                                   memberCountCallback
                                                   );

            RtmWrapperDll.login(token, username);
        }
Beispiel #10
0
        public override void QueryPeersOnlineStatus(string peerIds, ref long requestId)
        {
            var fPeerIds = peerIds.Split(' ');

            RtmWrapperDll.queryPeersOnlineStatus(fPeerIds, fPeerIds.Length, QueryPeersOnlineStatusCallback);
        }
Beispiel #11
0
 public override void SendPeerMessage(string peerId, string msg, bool enableOffline)
 {
     RtmWrapperDll.sendMessageToPeer(msg, peerId, onSendPeerMessage);
 }
Beispiel #12
0
 public override void Initialize()
 {
     Debug.Log(RtmWrapperDll.getSDKVersion());
 }
Beispiel #13
0
 public override void GetChannelMemberCount(string[] channelIds, int channelCount, ref long reqId)
 {
     RtmWrapperDll.getChannelMemberCount(channels.ToArray(), channels.Count, ref reqId);
 }
Beispiel #14
0
 public override void Initialize()
 {
     Debug.Log("init: " + RtmWrapperDll.initialize());
 }
Beispiel #15
0
        public override void QueryPeersOnlineStatus(string peerIdsUnformatted, ref long requestId)
        {
            var peerIds = peerIdsUnformatted.Split(' ');

            Debug.Log("QUERY:  " + RtmWrapperDll.queryPeersOnlineStatus(peerIds, peerIds.Length, ref requestId));;
        }
Beispiel #16
0
 public override void GetChannelMemberCount(string[] channelIds, int channelCount, ref long reqId)
 {
     RtmWrapperDll.getChannelMemberCount(channelIds, channelIds.Length, ChannelMemberCountCallback);
 }
Beispiel #17
0
 public override void Release()
 {
     RtmWrapperDll.release();
 }