备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,315 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using com.fpnn.proto;
|
||||
|
||||
namespace com.fpnn.rtm
|
||||
{
|
||||
public partial class RTMClient
|
||||
{
|
||||
//===========================[ Add Friends ]=========================//
|
||||
public bool AddFriends(DoneDelegate callback, HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("addfriends");
|
||||
quest.Param("friends", uids);
|
||||
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int AddFriends(HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("addfriends");
|
||||
quest.Param("friends", uids);
|
||||
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
return answer.ErrorCode();
|
||||
}
|
||||
|
||||
//===========================[ Delete Friends ]=========================//
|
||||
public bool DeleteFriends(DoneDelegate callback, HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("delfriends");
|
||||
quest.Param("friends", uids);
|
||||
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int DeleteFriends(HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("delfriends");
|
||||
quest.Param("friends", uids);
|
||||
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
return answer.ErrorCode();
|
||||
}
|
||||
|
||||
//===========================[ Get Friends ]=========================//
|
||||
//-- Action<friend_uids, errorCode>
|
||||
public bool GetFriends(Action<HashSet<long>, int> callback, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("getfriends");
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => {
|
||||
|
||||
HashSet<long> friends = null;
|
||||
|
||||
if (errorCode == fpnn.ErrorCode.FPNN_EC_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
friends = WantLongHashSet(answer, "uids");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorCode = fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE;
|
||||
}
|
||||
}
|
||||
callback(friends, errorCode);
|
||||
}, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int GetFriends(out HashSet<long> friends, int timeout = 0)
|
||||
{
|
||||
friends = null;
|
||||
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("getfriends");
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
|
||||
if (answer.IsException())
|
||||
return answer.ErrorCode();
|
||||
|
||||
try
|
||||
{
|
||||
friends = WantLongHashSet(answer, "uids");
|
||||
return fpnn.ErrorCode.FPNN_EC_OK;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================[ Add Blacklist ]=========================//
|
||||
public bool AddBlacklist(DoneDelegate callback, HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("addblacks");
|
||||
quest.Param("blacks", uids);
|
||||
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int AddBlacklist(HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("addblacks");
|
||||
quest.Param("blacks", uids);
|
||||
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
return answer.ErrorCode();
|
||||
}
|
||||
|
||||
//===========================[ Delete Blacklist ]=========================//
|
||||
public bool DeleteBlacklist(DoneDelegate callback, HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("delblacks");
|
||||
quest.Param("blacks", uids);
|
||||
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int DeleteBlacklist(HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("delblacks");
|
||||
quest.Param("blacks", uids);
|
||||
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
return answer.ErrorCode();
|
||||
}
|
||||
|
||||
//===========================[ Get Blacklist ]=========================//
|
||||
//-- Action<uids, errorCode>
|
||||
public bool GetBlacklist(Action<HashSet<long>, int> callback, int timeout = 0)
|
||||
{
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
{
|
||||
if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = new Quest("getblacks");
|
||||
bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => {
|
||||
|
||||
HashSet<long> friends = null;
|
||||
|
||||
if (errorCode == fpnn.ErrorCode.FPNN_EC_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
friends = WantLongHashSet(answer, "uids");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorCode = fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE;
|
||||
}
|
||||
}
|
||||
callback(friends, errorCode);
|
||||
}, timeout);
|
||||
|
||||
if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
|
||||
ClientEngine.RunTask(() =>
|
||||
{
|
||||
callback(null, fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
|
||||
});
|
||||
|
||||
return asyncStarted;
|
||||
}
|
||||
|
||||
public int GetBlacklist(out HashSet<long> uids, int timeout = 0)
|
||||
{
|
||||
uids = null;
|
||||
|
||||
TCPClient client = GetCoreClient();
|
||||
if (client == null)
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION;
|
||||
|
||||
Quest quest = new Quest("getblacks");
|
||||
Answer answer = client.SendQuest(quest, timeout);
|
||||
|
||||
if (answer.IsException())
|
||||
return answer.ErrorCode();
|
||||
|
||||
try
|
||||
{
|
||||
uids = WantLongHashSet(answer, "uids");
|
||||
return fpnn.ErrorCode.FPNN_EC_OK;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return fpnn.ErrorCode.FPNN_EC_CORE_INVALID_PACKAGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user