static void SendRoomMessageInSync(RTMClient client, long roomId, byte mtype) { long mtime; int errorCode = client.SendRoomMessage(out mtime, roomId, mtype, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send text message to room " + roomId + " in sync successed, mtime is " + mtime); } else { Debug.Log("Send text message to room " + roomId + " in sync failed."); } errorCode = client.SendRoomMessage(out mtime, roomId, mtype, binaryMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send binary message to room " + roomId + " in sync successed, mtime is " + mtime); } else { Debug.Log("Send binary message to room " + roomId + " in sync failed."); } }
public void StartTest(byte[] fileBytes) { SingleClientConcurrency self = this; this._client = new RTMClient( "52.83.245.22:13325", 11000001, 777779, "FA77FB4FA1E19E3EA7A9500DC6D9649C", RTMConfig.TRANS_LANGUAGE.en, new Dictionary <string, string>(), true, 20 * 1000, true ); this._client.GetEvent().AddListener("login", (evd) => { if (evd.GetException() != null) { Debug.LogError(evd.GetException()); return; } lock (self_locker) { self._endpoint = Convert.ToString(evd.GetPayload()); Debug.Log("[ CONCURRENCY ] login! endpoint: " + self._endpoint); } }); this._client.GetEvent().AddListener("close", (evd) => { Debug.Log("[ CONCURRENCY ] closed!"); }); this._client.GetEvent().AddListener("error", (evd) => { Debug.LogError(evd.GetException()); }); this.StartThread(); }
static void GetGroupMemberCountWithOnlineMemberCount(RTMClient client, long groupId) { int errorCode = client.GetGroupCount(out int memberCount, out int onlineCount, groupId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine($"Get group members count with online member count in sync failed, error code is {errorCode}."); } else { Console.WriteLine($"Get group members count with online member count in sync success, total {memberCount}, online {onlineCount}"); } bool status = client.GetGroupCount((int memberCount, int onlineCount, int errorCode) => { if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine($"Get group members count with online member count in async success, total {memberCount}, online {onlineCount}"); } else { Console.WriteLine($"Get group members count with online member count in async failed, error code is {errorCode}."); } }, groupId); if (!status) { Console.WriteLine("Launch group members count with online member count in async failed."); } System.Threading.Thread.Sleep(3 * 1000); }
static void SendRoomMessageInSync(RTMClient client, long roomId, byte mtype) { long messageId; int errorCode = client.SendRoomMessage(out messageId, roomId, mtype, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Send text message to room {0} in sync successed, messageId is {1}.", roomId, messageId); } else { Console.WriteLine("Send text message to room {0} in sync failed.", roomId); } errorCode = client.SendRoomMessage(out messageId, roomId, mtype, binaryMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Send binary message to room {0} in sync successed, messageId is {1}.", roomId, messageId); } else { Console.WriteLine("Send binary message to room {0} in sync failed.", roomId); } }
public BaseMicrophone() { sendClient = new RTMClient( "52.83.245.22:13325", 11000001, 778899, TOKEN_778899, RTMConfig.TRANS_LANGUAGE.en, new Dictionary <string, string>(), true, 20 * 1000, true ); sendClient.GetEvent().AddListener("login", (evd) => { if (evd.GetException() == null) { Debug.Log("778899 login!"); } else { Debug.Log(evd.GetException()); } }); sendClient.GetEvent().AddListener("error", (evd) => { Debug.Log(evd.GetException()); }); sendClient.Login(null); }
public IEnumerator Client_Login_Login() { int closeCount = 0; int loginCount = 0; RTMClient client = new RTMClient( this._dispatch, this._pid, this._uid, this._token, null, new Dictionary <string, string>(), true, 20 * 1000, true ); client.GetEvent().AddListener("login", (evd) => { loginCount++; }); client.GetEvent().AddListener("close", (evd) => { closeCount++; }); client.Login(null); client.Login(null); yield return(new WaitForSeconds(2.0f)); client.Destroy(); yield return(new WaitForSeconds(1.0f)); Assert.AreEqual(1, loginCount); Assert.AreEqual(1, closeCount); }
static void GetBroadcastChatInSync(RTMClient client, int count) { long beginMsec = 0; long endMsec = 0; long lastId = 0; int fetchedCount = 0; while (count > 0) { int maxCount = (count > 20) ? 20 : count; count -= maxCount; int errorCode = client.GetBroadcastChat(out HistoryMessageResult result, true, maxCount, beginMsec, endMsec, lastId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("Get broadcast history chat in sync failed, current fetched {0} items, error Code {1}", fetchedCount, errorCode); Debug.Log(sb.ToString()); return; } fetchedCount += result.count; DisplayHistoryMessages(result.messages); beginMsec = result.beginMsec; endMsec = result.endMsec; lastId = result.lastId; } Debug.Log("Get broadcast history chat total fetched " + fetchedCount + " items"); }
static void GetGroupMemberCount(RTMClient client, long groupId) { int errorCode = client.GetGroupCount(out int memberCount, groupId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log($"Get group members count in sync failed, error code is {errorCode}."); } else { Debug.Log($"Get group members count in sync success, total {memberCount}"); } bool status = client.GetGroupCount((int memberCount2, int errorCode2) => { if (errorCode2 == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log($"Get group members count in async success, total {memberCount2}"); } else { Debug.Log($"Get group members count in async failed, error code is {errorCode2}."); } }, groupId); if (!status) { Debug.Log("Launch group members count in async failed."); } System.Threading.Thread.Sleep(3 * 1000); }
static void SendGroupMessageInSync(RTMClient client, long groupId, byte mtype) { long messageId; int errorCode = client.SendGroupMessage(out messageId, groupId, mtype, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send text message to group " + groupId + " in sync successed, messageId is " + messageId); } else { Debug.Log("Send text message to group " + groupId + " in sync failed."); } errorCode = client.SendGroupMessage(out messageId, groupId, mtype, binaryMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send binary message to group " + groupId + " in sync successed, messageId is " + messageId); } else { Debug.Log("Send binary message to group " + groupId + " in sync failed."); } }
static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Usage: RTMFiles <rtm-endpoint> <projectId> <uid> <token>"); return; } //-- Testing only // ManualInitForTesting(); string rtmEndpoint = args[0]; long projectId = Int64.Parse(args[1]); long uid = Int64.Parse(args[2]); string token = args[3]; RTMClient client = LoginRTM(rtmEndpoint, projectId, uid, token); if (client == null) { return; } SendP2PFileInAsync(client, peerUid, MessageType.NormalFile); SendP2PFileInSync(client, peerUid, MessageType.NormalFile); SendGroupFileInAsync(client, groupId, MessageType.NormalFile); SendGroupFileInSync(client, groupId, MessageType.NormalFile); EnterRoom(client, roomId); SendRoomFileInAsync(client, roomId, MessageType.NormalFile); SendRoomFileInSync(client, roomId, MessageType.NormalFile); }
static void GetGroupUnreadInSync(RTMClient client, HashSet <long> groupIds, HashSet <byte> mtypes) { Dictionary <long, int> unreadMap; int errorCode = client.GetGroupUnread(out unreadMap, groupIds); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Fetch group unread in sync successful."); foreach (KeyValuePair <long, int> kvp in unreadMap) { Console.WriteLine($" -- group: {kvp.Key}, unread message {kvp.Value}"); } } else { Console.WriteLine($"Fetch group unread in sync failed. Error code {errorCode}"); } errorCode = client.GetGroupUnread(out unreadMap, groupIds, mtypes); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Fetch group unread with mTypes in sync successful."); foreach (KeyValuePair <long, int> kvp in unreadMap) { Console.WriteLine($" -- group: {kvp.Key}, unread message {kvp.Value}"); } } else { Console.WriteLine($"Fetch group unread with mTypes in sync failed. Error code {errorCode}"); } }
public void Start(string endpoint, long pid, long uid, string token) { client = LoginRTM(endpoint, pid, uid, token); if (client == null) { Debug.Log("User " + uid + " login RTM failed."); return; } SendP2PChatInAsync(client, peerUid); SendP2PChatInSync(client, peerUid); SendP2PCmdInAsync(client, peerUid); SendP2PCmdInSync(client, peerUid); SendGroupChatInAsync(client, groupId); SendGroupChatInSync(client, groupId); SendGroupCmdInAsync(client, groupId); SendGroupCmdInSync(client, groupId); if (EnterRoom(client, roomId)) { SendRoomChatInAsync(client, roomId); SendRoomChatInSync(client, roomId); SendRoomCmdInAsync(client, roomId); SendRoomCmdInSync(client, roomId); } Debug.Log("Running for receiving server pushed chat & cmd &c audio if those are being demoed ..."); }
public void Start(string endpoint, long pid, long uid, string token) { client = LoginRTM(endpoint, pid, uid, token); if (client == null) { Debug.Log("User " + uid + " login RTM failed."); return; } AddFriends(client, new HashSet <long>() { 123456, 234567, 345678, 456789 }); GetFriends(client); DeleteFriends(client, new HashSet <long>() { 234567, 345678 }); System.Threading.Thread.Sleep(2000); //-- Wait for server sync action. GetFriends(client); Debug.Log("Demo completed."); }
//------------------------[ Message Histories Demo ]-------------------------// static void GetP2PMessageInSync(RTMClient client, long peerUid, int count) { long beginMsec = 0; long endMsec = 0; long lastId = 0; int fetchedCount = 0; while (count > 0) { int maxCount = (count > 20) ? 20 : count; count -= maxCount; int errorCode = client.GetP2PMessage(out HistoryMessageResult result, peerUid, true, maxCount, beginMsec, endMsec, lastId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Get P2P history message with user " + peerUid + " in sync failed, current fetched " + fetchedCount + " items, error Code " + errorCode); return; } fetchedCount += result.count; DisplayHistoryMessages(result.messages); beginMsec = result.beginMsec; endMsec = result.endMsec; lastId = result.lastId; } Debug.Log("Get P2P history message total fetched " + fetchedCount + " items"); }
static void GetBroadcastChatInSync(RTMClient client, int count) { long beginMsec = 0; long endMsec = 0; long lastId = 0; int fetchedCount = 0; while (count > 0) { int maxCount = (count > 20) ? 20 : count; count -= maxCount; int errorCode = client.GetBroadcastChat(out HistoryMessageResult result, true, maxCount, beginMsec, endMsec, lastId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Get broadcast history chat in sync failed, current fetched {0} items, error Code {1}", fetchedCount, errorCode); return; } fetchedCount += result.count; DisplayHistoryMessages(result.messages); beginMsec = result.beginMsec; endMsec = result.endMsec; lastId = result.lastCursorId; } Console.WriteLine("Get broadcast history chat total fetched {0} items", fetchedCount); }
//------------------------[ Get P2P & Group Unread ]-------------------------// static void GetP2PUnreadInSync(RTMClient client, HashSet <long> uids, HashSet <byte> mtypes) { Dictionary <long, int> unreadMap; int errorCode = client.GetP2PUnread(out unreadMap, uids); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Fetch P2P unread in sync successful."); foreach (KeyValuePair <long, int> kvp in unreadMap) { Debug.Log($" -- peer: {kvp.Key}, unread message {kvp.Value}"); } } else { Debug.Log($"Fetch P2P unread in sync failed. Error code {errorCode}"); } errorCode = client.GetP2PUnread(out unreadMap, uids, mtypes); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Fetch P2P unread with mTypes in sync successful."); foreach (KeyValuePair <long, int> kvp in unreadMap) { Debug.Log($" -- peer: {kvp.Key}, unread message {kvp.Value}"); } } else { Debug.Log($"Fetch P2P unread with mTypes in sync failed. Error code {errorCode}"); } }
static RTMClient LoginRTM(string rtmEndpoint, long pid, long uid, string token) { RTMClient client = new RTMClient(rtmEndpoint, pid, uid, new example.common.RTMExampleQuestProcessor()); int errorCode = client.Login(out bool ok, token, new Dictionary <string, string>() { { "attr1", "demo 123" }, { "attr2", " demo 234" }, });
static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Usage: RTMHistories <rtm-endpoint> <projectId> <uid> <token>"); return; } //-- Testing only // ManualInitForTesting(); string rtmEndpoint = args[0]; long projectId = Int64.Parse(args[1]); long uid = Int64.Parse(args[2]); string token = args[3]; RTMClient client = LoginRTM(rtmEndpoint, projectId, uid, token); if (client == null) { return; } EnterRoom(client, roomId); int fetchCount = 100; Console.WriteLine("\n================[ Get P2P Message {0} items ]==================", fetchCount); GetP2PMessageInSync(client, peerUid, fetchCount); Console.WriteLine("\n================[ Get Group Message {0} items ]==================", fetchCount); GetGroupMessageInSync(client, groupId, fetchCount); Console.WriteLine("\n================[ Get Room Message {0} items ]==================", fetchCount); GetRoomMessageInSync(client, roomId, fetchCount); Console.WriteLine("\n================[ Get Broadcast Message {0} items ]==================", fetchCount); GetBroadcastMessageInSync(client, fetchCount); Console.WriteLine("\n================[ Get P2P Chat {0} items ]==================", fetchCount); GetP2PChatInSync(client, peerUid, fetchCount); Console.WriteLine("\n================[ Get Group Chat {0} items (sync) ]==================", fetchCount); GetGroupChatInSync(client, groupId, fetchCount); Console.WriteLine("\n================[ Get Group Chat {0} items (async) ]==================", fetchCount); GetGroupChatInASync(client, groupId, fetchCount); Thread.Sleep(3000); Console.WriteLine("\n================[ Get Room Chat {0} items ]==================", fetchCount); GetRoomChatInSync(client, roomId, fetchCount); Console.WriteLine("\n================[ Get Broadcast Chat {0} items ]==================", fetchCount); GetBroadcastChatInSync(client, fetchCount); }
public void StartTest(byte[] fileBytes) { this._fileBytes = fileBytes; this._client = new RTMClient( "52.83.245.22:13325", 11000001, this._uid, this._token, // "rtm-intl-frontgate.funplus.com:13325", // 11000002, // 777779, // "BE3732174850E479209443BCCDF4747D", // "52.83.245.22:13325", // 1000012, // 654321, // "63B3F146B2A1DA8660B167D26A610C0D", // "rtm-intl-frontgate.funplus.com:13325", // 11000001, // 777779, // "12861748F2D641907D181D1CDB6DF174", RTMConfig.TRANS_LANGUAGE.en, new Dictionary <string, string>(), true, 20 * 1000, true ); RTMProcessor processor = this._client.GetProcessor(); processor.AddPushService(RTMConfig.SERVER_PUSH.recvMessage, (data) => { Debug.Log("[recvMessage]: " + Json.SerializeToString(data)); Debug.Log("[recvMessage]: " + data["msg"]); }); TestCase self = this; this._client.GetEvent().AddListener("login", (evd) => { Exception ex = evd.GetException(); if (ex != null) { Debug.Log("TestCase connect err: " + ex.Message); } else { Debug.Log("TestCase connect! gate: " + evd.GetPayload()); self.StartThread(); } }); this._client.GetEvent().AddListener("close", (evd) => { Debug.Log("TestCase closed!"); }); this._client.GetEvent().AddListener("error", (evd) => { Debug.Log("TestCase error: " + evd.GetException()); }); this._client.Login(null); }
public void Start(string endpoint, long pid, long uid, string token) { client = LoginRTM(endpoint, pid, uid, token); if (client == null) { Debug.Log("User " + uid + " login RTM failed."); return; } GetOnlineUsers(client, new HashSet <long>() { 99688848, 123456, 234567, 345678, 456789 }); SetUserInfos(client, "This is public info", "This is private info"); GetUserInfos(client); Debug.Log("======== ========="); SetUserInfos(client, "", "This is private info"); GetUserInfos(client); Debug.Log("======== ========="); SetUserInfos(client, "This is public info", ""); GetUserInfos(client); Debug.Log("======== only change the private infos ========="); SetUserInfos(client, null, "balabala"); GetUserInfos(client); SetUserInfos(client, "This is public info", "This is private info"); client.Bye(); Debug.Log("======== user relogin ========="); client = LoginRTM(endpoint, pid, uid, token); if (client == null) { return; } GetUserInfos(client); GetUsersInfos(client, new HashSet <long>() { 99688848, 123456, 234567, 345678, 456789 }); Debug.Log("============== Demo completed ================"); }
static void DeleteFriends(RTMClient client, HashSet <long> uids) { int errorCode = client.DeleteFriends(uids); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Delete friends in sync failed, error code is " + errorCode); } else { Debug.Log("Delete friends in sync success"); } }
static void SendGroupCmdInSync(RTMClient client, long groupId) { int errorCode = client.SendGroupCmd(out long mtime, groupId, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send cmd message to group " + groupId + " in sync successed, mtime is " + mtime); } else { Debug.Log("Send cmd message to group " + groupId + " in sync failed."); } }
static void SendP2PCmdInSync(RTMClient client, long peerUid) { int errorCode = client.SendCmd(out long mtime, peerUid, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send cmd message to user " + peerUid + " in sync successed, mtime is " + mtime); } else { Debug.Log("Send cmd message to user " + peerUid + " in sync failed."); } }
static void SetUserInfos(RTMClient client, string publicInfos, string privateInfos) { int errorCode = client.SetUserInfo(publicInfos, privateInfos); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Set user infos in sync failed, error code is " + errorCode); } else { Debug.Log("Set user infos in sync successed."); } }
static void DeleteGroupMembers(RTMClient client, long groupId, HashSet <long> uids) { int errorCode = client.DeleteGroupMembers(groupId, uids); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Delete group members in sync failed, error code is " + errorCode); } else { Debug.Log("Delete group members in sync successed."); } }
static void SendRoomFileInSync(RTMClient client, long roomId, MessageType type) { int errorCode = client.SendRoomFile(out long messageId, roomId, type, fileContent, filename); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Send file to room {0} in sync successed, messageId is {1}.", roomId, messageId); } else { Console.WriteLine("Send file to room {0} in sync failed, error code {1}.", roomId, errorCode); } }
static void SendGroupCmdInSync(RTMClient client, long groupId) { int errorCode = client.SendGroupCmd(out long messageId, groupId, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Send cmd message to group {0} in sync successed, messageId is {1}.", groupId, messageId); } else { Console.WriteLine("Send cmd message to group {0} in sync failed.", groupId); } }
static void SendP2PChatInSync(RTMClient client, long peerUid) { int errorCode = client.SendChat(out long messageId, peerUid, textMessage); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Console.WriteLine("Send chat message to user {0} in sync successed, messageId is {1}.", peerUid, messageId); } else { Console.WriteLine("Send chat message to user {0} in sync failed.", peerUid); } }
static void SendRoomFileInSync(RTMClient client, long roomId, MessageType mtype) { int errorCode = client.SendRoomFile(out long messageId, roomId, mtype, fileContent, filename); if (errorCode == com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Send file to room " + roomId + " in sync successed, messageId is " + messageId); } else { Debug.Log("Send file to room " + roomId + " in sync failed, error code " + errorCode); } }
static void EnterRoom(RTMClient client, long roomId) { int errorCode = client.EnterRoom(roomId); if (errorCode != com.fpnn.ErrorCode.FPNN_EC_OK) { Debug.Log("Enter room " + roomId + " in sync failed."); } else { Debug.Log("Enter room " + roomId + " in sync successed."); } }