本文整理汇总了C#中Communicator.SendPayload方法的典型用法代码示例。如果您正苦于以下问题:C# Communicator.SendPayload方法的具体用法?C# Communicator.SendPayload怎么用?C# Communicator.SendPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Communicator
的用法示例。
在下文中一共展示了Communicator.SendPayload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAssets
public void GetAssets(Action<Response<IList<Asset>>> callback)
{
var payload = new Dictionary<string, object> {{"key", Key}};
var communicator = new Communicator(this);
communicator.SendPayload<IList<Asset>>(Communicator.Get, "assets", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<IList<Asset>> (r.Raw); }
if (callback != null) { callback(r); }
});
}
示例2: GetGameConfiguration
public void GetGameConfiguration(Action<Response<GameConfiguration>> callback)
{
var payload = new Dictionary<string, object>(0);
var communicator = new Communicator(this);
communicator.SendPayload<GameConfiguration>(Communicator.POST, "conf", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<GameConfiguration>(r.Raw); }
callback(r);
});
}
示例3: AchievementEarned
public void AchievementEarned(string achievementId, string userName, string uniqueIdentifier, Action<Response<Achievement>> callback)
{
var payload = new Dictionary<string, object> { { "aid", achievementId }, { "username", userName }, { "userkey", uniqueIdentifier } };
var communicator = new Communicator(this);
communicator.SendPayload<Achievement>(Communicator.Post, "achievements", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<Achievement>(r.Raw); }
if (callback != null) { callback(r); }
});
}
示例4: LogAsync
public void LogAsync(string message, Action<LogResponse> callback)
{
var communicator = new Communicator(this);
var callbackWrapper = callback == null ? (Action<Response>) null : r =>
{
if (r.Success)
{
callback(JsonConvert.DeserializeObject<LogResponse>(r.Raw));
}
};
communicator.SendPayload(Communicator.POST, string.Concat("inputs/", _inputKey), message, callbackWrapper);
}
示例5: GetGameVersion
public void GetGameVersion(Action<Response<int>> callback)
{
var payload = new Dictionary<string, object>(0);
var communicator = new Communicator(this);
communicator.SendPayload<int>(Communicator.POST, "conf/version", payload, r =>
{
if (r.Success)
{
var container = ((JContainer) JsonConvert.DeserializeObject(r.Raw))["version"];
r.Data = container == null ? 0 : container.Value<int>();
}
callback(r);
});
}
示例6: LogAsync
public void LogAsync(string message, Action<LogResponse> callback)
{
var communicator = new Communicator(this);
var callbackWrapper = callback == null ? (Action<Response>)null : r =>
{
if (r.Success)
{
var js = new JavaScriptSerializer();
callback(js.Deserialize<LogResponse>(r.Raw));
}
};
try{
communicator.SendPayload(Communicator.POST, string.Format(Routes.Log, _inputKey), message, callbackWrapper);
}catch(Exception ex)
{
// yes I know it's bad)
}
}
示例7: GetYesterdaysLeaders
public void GetYesterdaysLeaders(string leaderboardId, Action<Response<LeaderboardScores>> callback)
{
ValidationHelper.AssertValidId(leaderboardId, "leaderboardId");
var payload = new Dictionary<string, object> { { "leaderboard_id", leaderboardId } };
var communicator = new Communicator(this);
communicator.SendPayload<LeaderboardScores>(Communicator.POST, "scores/yesterdays_leaders", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<LeaderboardScores>(r.Raw); }
callback(r);
});
}
示例8: GetUserSettings
public void GetUserSettings(string userName, string uniqueIdentifier, Action<Response<UserSettings>> callback)
{
ValidationHelper.AssertNotNullOrEmpty(userName, 20, "username");
ValidationHelper.AssertNotNullOrEmpty(uniqueIdentifier, 50, "unique identifier");
var payload = new Dictionary<string, object> { { "username", userName }, { "unique", uniqueIdentifier } };
var communicator = new Communicator(this);
communicator.SendPayload<UserSettings>(Communicator.POST, "conf/my", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<UserSettings>(r.Raw); }
callback(r);
});
}
示例9: Log
public void Log(string message, bool json, Action<LogResponse> callback)
{
var communicator = new Communicator(this);
var callbackWrapper = callback == null ? (Action<Response>) null : r =>
{
if (r.Success)
{
var res = JsonConvert.DeserializeObject<LogResponse>(r.Raw);
res.Success = true;
callback(res);
}
else
{
var res = new LogResponse{ Success = false };
callback(res);
}
};
communicator.SendPayload(Communicator.POST, string.Concat("inputs/", _inputKey), message, json, callbackWrapper);
}
示例10: GetRank
public void GetRank(string leaderboardId, int score, LeaderboardScope scope, Action<Response<int>> callback)
{
var payload = new Dictionary<string, object> { { "lid", leaderboardId }, { "score", score }, { "scopes", (int)scope } };
var communicator = new Communicator(this);
communicator.SendPayload<int>(Communicator.Get, "ranks", payload, r =>
{
if (r.Success)
{
r.Data = JsonConvert.DeserializeObject<int>(r.Raw);
}
callback(r);
});
}
示例11: GetRanks
public void GetRanks(string leaderboardId, int score, LeaderboardScope[] scopes, Action<Response<Ranks>> callback)
{
var realScopes = new int[scopes.Length];
for (var i = 0; i < scopes.Length; ++i)
{
realScopes[i] = (int)scopes[i];
}
var payload = new Dictionary<string, object> { { "lid", leaderboardId }, { "score", score }, { "scopes", realScopes } };
var communicator = new Communicator(this);
communicator.SendPayload<Ranks>(Communicator.Get, "ranks", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<Ranks>(r.Raw); }
callback(r);
});
}
示例12: LogApplicationStart
public void LogApplicationStart(string uniqueIdentifier)
{
var payload = new Dictionary<string, object> { { "unique", uniqueIdentifier }};
var communicator = new Communicator(this);
communicator.SendPayload<object>(Communicator.PUT, "analytics/start", payload, null);
}
示例13: LogApplicationStart
public void LogApplicationStart(string uniqueIdentifier, Action<Response> callback)
{
var payload = new Dictionary<string, object> { { "userkey", uniqueIdentifier } };
var communicator = new Communicator(this);
communicator.SendPayload<object>(Communicator.Post, "stats", payload, r =>
{
if (callback != null) { callback(r); }
});
}
示例14: SaveScore
public void SaveScore(string leaderboardId, Score score, string uniqueIdentifier, Action<Response<SavedScore>> callback)
{
var payload = new Dictionary<string, object> {{"lid", leaderboardId}, {"username", score.UserName}, {"userkey", uniqueIdentifier}, {"points", score.Points}, {"data", score.Data}};
var communicator = new Communicator(this);
communicator.SendPayload<SavedScore>(Communicator.Post, "scores", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<SavedScore>(r.Raw); }
if (callback != null) { callback(r); }
});
}
示例15: GetLeaderboard
private void GetLeaderboard(IDictionary<string, object> payload, Action<Response<LeaderboardScores>> callback)
{
var communicator = new Communicator(this);
communicator.SendPayload<LeaderboardScores>(Communicator.Get, "scores", payload, r =>
{
if (r.Success) { r.Data = JsonConvert.DeserializeObject<LeaderboardScores>(r.Raw); }
callback(r);
});
}