//-------------[ P2P History Messages ]---------------------// public bool GetP2PMessage(HistoryMessageDelegate callback, long peerUid, bool desc, int count, long beginMsec = 0, long endMsec = 0, long lastId = 0, List <byte> mtypes = null, int timeout = 0) { TCPClient client = GetCoreClient(); if (client == null) { return(false); } Quest quest = new Quest("getp2pmsg"); quest.Param("ouid", peerUid); quest.Param("desc", desc); quest.Param("num", count); quest.Param("begin", beginMsec); quest.Param("end", endMsec); quest.Param("lastid", lastId); if (mtypes != null) { quest.Param("mtypes", mtypes); } return(client.SendQuest(quest, (Answer answer, int errorCode) => { if (errorCode == fpnn.ErrorCode.FPNN_EC_OK) { HistoryMessageResult result; try { result = BuildHistoryMessageResult(answer); AdjustHistoryMessageResultForP2PMessage(uid, peerUid, result); } catch (Exception) { errorCode = fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE; result = new HistoryMessageResult(); } callback(result.count, result.lastId, result.beginMsec, result.endMsec, result.messages, errorCode); } else { callback(0, 0, 0, 0, null, errorCode); } }, timeout)); }
//-------------[ Broadcast History Messages ]---------------------// public bool GetBroadcastMessage(HistoryMessageDelegate callback, bool desc, int count, long beginMsec = 0, long endMsec = 0, long lastId = 0, List <byte> mtypes = null, int timeout = 0) { TCPClient client = GetCoreClient(); if (client == null) { if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse) { ClientEngine.RunTask(() => { callback(0, 0, 0, 0, null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION); }); } return(false); } Quest quest = new Quest("getbroadcastmsg"); quest.Param("desc", desc); quest.Param("num", count); quest.Param("begin", beginMsec); quest.Param("end", endMsec); quest.Param("lastid", lastId); if (mtypes != null) { quest.Param("mtypes", mtypes); } bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { if (errorCode == fpnn.ErrorCode.FPNN_EC_OK) { HistoryMessageResult result; try { result = BuildHistoryMessageResult(0, answer); } catch (Exception) { errorCode = fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE; result = new HistoryMessageResult(); } callback(result.count, result.lastCursorId, result.beginMsec, result.endMsec, result.messages, errorCode); } else { callback(0, 0, 0, 0, null, errorCode); } }, timeout); if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse) { ClientEngine.RunTask(() => { callback(0, 0, 0, 0, null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION); }); } return(asyncStarted); }
public bool GetP2PChat(HistoryMessageDelegate callback, long peerUid, bool desc, int count, long beginMsec = 0, long endMsec = 0, long lastId = 0, int timeout = 0) { return(GetP2PMessage(callback, peerUid, desc, count, beginMsec, endMsec, lastId, chatMTypes, timeout)); }