Merge pull request #87 from weakish/en-api-doc

docs: api-doc zh -> en
oneRain 2020-07-29 11:34:01 +08:00 committed by GitHub
commit 3aaa14cdcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 376 additions and 1171 deletions

View File

@ -2,18 +2,18 @@
namespace LeanCloud { namespace LeanCloud {
/// <summary> /// <summary>
/// LeanCloud 异常 /// LeanCloud Exceptions
/// </summary> /// </summary>
public class LCException : Exception { public class LCException : Exception {
/// <summary> /// <summary>
/// 错误码 /// Error code
/// </summary> /// </summary>
public int Code { public int Code {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 错误信息 /// Error message
/// </summary> /// </summary>
public new string Message { public new string Message {
get; set; get; set;

View File

@ -3,7 +3,7 @@ using System.Threading.Tasks;
namespace LeanCloud.Common { namespace LeanCloud.Common {
/// <summary> /// <summary>
/// 为 Json 解析提供异步接口 /// Serialize and deserialize
/// </summary> /// </summary>
public static class LCJsonUtils { public static class LCJsonUtils {
public static async Task<string> SerializeObjectAsync(object obj) { public static async Task<string> SerializeObjectAsync(object obj) {

View File

@ -1,19 +1,7 @@
namespace LeanCloud { namespace LeanCloud {
/// <summary>
/// 日志级别
/// </summary>
public enum LCLogLevel { public enum LCLogLevel {
/// <summary>
/// 调试级别
/// </summary>
Debug, Debug,
/// <summary>
/// 警告级别
/// </summary>
Warn, Warn,
/// <summary>
/// 错误级别
/// </summary>
Error, Error,
} }
} }

View File

@ -3,11 +3,11 @@ using System.Text;
namespace LeanCloud { namespace LeanCloud {
/// <summary> /// <summary>
/// 日志类 /// Logger
/// </summary> /// </summary>
public static class LCLogger { public static class LCLogger {
/// <summary> /// <summary>
/// 日志回调接口,方便开发者调试 /// Configures the logger.
/// </summary> /// </summary>
/// <value>The log delegate.</value> /// <value>The log delegate.</value>
public static Action<LCLogLevel, string> LogDelegate { public static Action<LCLogLevel, string> LogDelegate {

View File

@ -10,45 +10,28 @@ using LeanCloud.Realtime.Internal.Connection;
namespace LeanCloud.LiveQuery.Internal { namespace LeanCloud.LiveQuery.Internal {
public class LCLiveQueryConnection { public class LCLiveQueryConnection {
/// <summary>
/// 发送超时
/// </summary>
private const int SEND_TIMEOUT = 10000; private const int SEND_TIMEOUT = 10000;
/// <summary> /// <summary>
/// 最大重连次数,超过后重置 Router 缓存后再次尝试重连 /// After exceeding this limit, will reset the Router cache and try to reconnect again.
/// </summary> /// </summary>
private const int MAX_RECONNECT_TIMES = 10; private const int MAX_RECONNECT_TIMES = 10;
/// <summary>
/// 重连间隔
/// </summary>
private const int RECONNECT_INTERVAL = 10000; private const int RECONNECT_INTERVAL = 10000;
/// <summary>
/// 子协议
/// </summary>
private const string SUB_PROTOCOL = "lc.json.3"; private const string SUB_PROTOCOL = "lc.json.3";
/// <summary>
/// 通知事件
/// </summary>
internal Action<Dictionary<string, object>> OnNotification; internal Action<Dictionary<string, object>> OnNotification;
/// <summary>
/// 断线事件
/// </summary>
internal Action OnDisconnect; internal Action OnDisconnect;
/// <summary>
/// 重连成功事件
/// </summary>
internal Action OnReconnected; internal Action OnReconnected;
internal string id; internal string id;
/// <summary> /// <summary>
/// 请求回调缓存 /// Request callback cache
/// </summary> /// </summary>
private readonly Dictionary<int, TaskCompletionSource<Dictionary<string, object>>> responses; private readonly Dictionary<int, TaskCompletionSource<Dictionary<string, object>>> responses;
@ -90,7 +73,7 @@ namespace LeanCloud.LiveQuery.Internal {
} }
/// <summary> /// <summary>
/// 重置连接 /// Resets connection
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
internal async Task Reset() { internal async Task Reset() {
@ -108,7 +91,7 @@ namespace LeanCloud.LiveQuery.Internal {
} }
/// <summary> /// <summary>
/// 发送请求,会在收到应答后返回 /// Sends the request. It will return after receiving a response.
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
@ -127,7 +110,7 @@ namespace LeanCloud.LiveQuery.Internal {
} }
/// <summary> /// <summary>
/// 发送文本消息 /// Sends text message.
/// </summary> /// </summary>
/// <param name="text"></param> /// <param name="text"></param>
/// <returns></returns> /// <returns></returns>
@ -142,7 +125,7 @@ namespace LeanCloud.LiveQuery.Internal {
} }
/// <summary> /// <summary>
/// 关闭连接 /// Closes the connection.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
internal async Task Close() { internal async Task Close() {

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace LeanCloud.LiveQuery.Internal { namespace LeanCloud.LiveQuery.Internal {
/// <summary> /// <summary>
/// LiveQuery 心跳控制器 /// LiveQuery heartbeat controller
/// </summary> /// </summary>
internal class LCLiveQueryHeartBeat : LCHeartBeat { internal class LCLiveQueryHeartBeat : LCHeartBeat {
private readonly LCLiveQueryConnection connection; private readonly LCLiveQueryConnection connection;

View File

@ -13,27 +13,27 @@ namespace LeanCloud.LiveQuery {
/// </summary> /// </summary>
public class LCLiveQuery { public class LCLiveQuery {
/// <summary> /// <summary>
/// 新对象创建事件 /// A new LCObject which fulfills the LCQuery you subscribe is created.
/// </summary> /// </summary>
public Action<LCObject> OnCreate; public Action<LCObject> OnCreate;
/// <summary> /// <summary>
/// 对象更新事件 /// An existing LCObject which fulfills the LCQuery you subscribe is updated.
/// </summary> /// </summary>
public Action<LCObject, ReadOnlyCollection<string>> OnUpdate; public Action<LCObject, ReadOnlyCollection<string>> OnUpdate;
/// <summary> /// <summary>
/// 对象被删除 /// An existing LCObject which fulfills the LCQuery you subscribe is deleted.
/// </summary> /// </summary>
public Action<string> OnDelete; public Action<string> OnDelete;
/// <summary> /// <summary>
/// 有新的满足条件的对象产生 /// An existing LCObject which doesn't fulfill the LCQuery is updated and now it fulfills the LCQuery.
/// </summary> /// </summary>
public Action<LCObject, ReadOnlyCollection<string>> OnEnter; public Action<LCObject, ReadOnlyCollection<string>> OnEnter;
/// <summary> /// <summary>
/// 不再满足条件 /// An existing LCObject which fulfills the LCQuery is updated and now it doesn't fulfill the LCQuery.
/// </summary> /// </summary>
public Action<LCObject, ReadOnlyCollection<string>> OnLeave; public Action<LCObject, ReadOnlyCollection<string>> OnLeave;
/// <summary> /// <summary>
/// 当一个用户登录成功 /// A LCUser logged in successfully.
/// </summary> /// </summary>
public Action<LCUser> OnLogin; public Action<LCUser> OnLogin;
@ -55,10 +55,7 @@ namespace LeanCloud.LiveQuery {
private static readonly string DeviceId = Guid.NewGuid().ToString(); private static readonly string DeviceId = Guid.NewGuid().ToString();
/// <summary>
/// 订阅
/// </summary>
/// <returns></returns>
public async Task Subscribe() { public async Task Subscribe() {
// TODO 判断当前连接情况 // TODO 判断当前连接情况
if (connection == null) { if (connection == null) {
@ -92,10 +89,6 @@ namespace LeanCloud.LiveQuery {
} }
} }
/// <summary>
/// 取消订阅
/// </summary>
/// <returns></returns>
public async Task Unsubscribe() { public async Task Unsubscribe() {
Dictionary<string, object> data = new Dictionary<string, object> { Dictionary<string, object> data = new Dictionary<string, object> {
{ "id", DeviceId }, { "id", DeviceId },

View File

@ -9,9 +9,6 @@ using LeanCloud.Realtime;
using static NUnit.Framework.TestContext; using static NUnit.Framework.TestContext;
/// <summary>
/// Emoji 消息
/// </summary>
class EmojiMessage : LCIMTypedMessage { class EmojiMessage : LCIMTypedMessage {
public const int EmojiMessageType = 1; public const int EmojiMessageType = 1;

View File

@ -5,25 +5,21 @@ using System.Threading.Tasks;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 聊天室 /// Chatroom
/// </summary> /// </summary>
public class LCIMChatRoom : LCIMConversation { public class LCIMChatRoom : LCIMConversation {
public LCIMChatRoom(LCIMClient client) : public LCIMChatRoom(LCIMClient client) :
base(client) { base(client) {
} }
/// <summary>
/// 获取在线用户数量
/// </summary>
/// <returns></returns>
public async Task<int> GetOnlineMembersCount() { public async Task<int> GetOnlineMembersCount() {
return await GetMembersCount(); return await GetMembersCount();
} }
/// <summary> /// <summary>
/// 获取在线用户 /// Gets online members.
/// </summary> /// </summary>
/// <param name="limit"></param> /// <param name="limit">Query limit, defaults to 50.</param>
/// <returns></returns> /// <returns></returns>
public async Task<ReadOnlyCollection<string>> GetOnlineMembers(int limit = 50) { public async Task<ReadOnlyCollection<string>> GetOnlineMembers(int limit = 50) {
return await Client.ConversationController.GetOnlineMembers(Id, limit); return await Client.ConversationController.GetOnlineMembers(Id, limit);

View File

@ -7,32 +7,32 @@ using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 普通对话 /// Conversation
/// </summary> /// </summary>
public class LCIMConversation { public class LCIMConversation {
/// <summary> /// <summary>
/// 对话 Id /// The ID of this conversation
/// </summary> /// </summary>
public string Id { public string Id {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 是否唯一 /// Indicates whether this conversation is normal and unique. The uniqueness is based on the members when creating.
/// </summary> /// </summary>
public bool Unique { public bool Unique {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 唯一 Id /// If this conversation is unique, then it will have a unique ID.
/// </summary> /// </summary>
public string UniqueId { public string UniqueId {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 对话名称 /// The name of this conversation.
/// </summary> /// </summary>
public string Name { public string Name {
get { get {
@ -44,14 +44,14 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 创建者 Id /// The creator of this conversation.
/// </summary> /// </summary>
public string CreatorId { public string CreatorId {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 成员 Id /// The members of this conversation.
/// </summary> /// </summary>
public ReadOnlyCollection<string> MemberIds { public ReadOnlyCollection<string> MemberIds {
get { get {
@ -60,7 +60,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 静音成员 Id /// Muted members of this conversation.
/// </summary> /// </summary>
public ReadOnlyCollection<string> MutedMemberIds { public ReadOnlyCollection<string> MutedMemberIds {
get { get {
@ -69,42 +69,42 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 未读消息数量 /// The count of the unread messages.
/// </summary> /// </summary>
public int Unread { public int Unread {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 最新的一条消息 /// The last message in this conversation.
/// </summary> /// </summary>
public LCIMMessage LastMessage { public LCIMMessage LastMessage {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 创建时间 /// The created date of this conversation.
/// </summary> /// </summary>
public DateTime CreatedAt { public DateTime CreatedAt {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 更新时间 /// The last updated date of this conversation.
/// </summary> /// </summary>
public DateTime UpdatedAt { public DateTime UpdatedAt {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 最新送达消息时间戳 /// The last timestamp of the delivered message.
/// </summary> /// </summary>
public long LastDeliveredTimestamp { public long LastDeliveredTimestamp {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 最新送达消息时间 /// The last date of the delivered message.
/// </summary> /// </summary>
public DateTime LastDeliveredAt { public DateTime LastDeliveredAt {
get { get {
@ -114,14 +114,14 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 最新已读消息时间戳 /// The last timestamp of the message which has been read by other clients.
/// </summary> /// </summary>
public long LastReadTimestamp { public long LastReadTimestamp {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 最新已读消息时间 /// The last date of the message which has been read by other clients.
/// </summary> /// </summary>
public DateTime LastReadAt { public DateTime LastReadAt {
get { get {
@ -131,9 +131,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 设置/获取对话属性 /// Custom attributes.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key">Custom attribute name.</param>
/// <returns></returns> /// <returns></returns>
public object this[string key] { public object this[string key] {
get { get {
@ -145,7 +145,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 是否已静音 /// Indicates whether offline notifications about this conversation has been muted.
/// </summary> /// </summary>
public bool IsMute { public bool IsMute {
get; private set; get; private set;
@ -170,7 +170,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取对话人数,或暂态对话的在线人数 /// The count of members of this conversation.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<int> GetMembersCount() { public async Task<int> GetMembersCount() {
@ -178,7 +178,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 将该会话标记为已读 /// Mark the last message of this conversation as read.
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <returns></returns> /// <returns></returns>
@ -191,9 +191,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 修改对话属性 /// Update attributes of this conversation.
/// </summary> /// </summary>
/// <param name="attributes"></param> /// <param name="attributes">Attributes to update.</param>
/// <returns></returns> /// <returns></returns>
public async Task UpdateInfo(Dictionary<string, object> attributes) { public async Task UpdateInfo(Dictionary<string, object> attributes) {
if (attributes == null || attributes.Count == 0) { if (attributes == null || attributes.Count == 0) {
@ -206,9 +206,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 添加用户到对话 /// Adds members to this conversation.
/// </summary> /// </summary>
/// <param name="clientIds">用户 Id</param> /// <param name="clientIds">Member list.</param>
/// <returns></returns> /// <returns></returns>
public virtual async Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) { public virtual async Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -220,9 +220,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 删除用户 /// Removes members from this conversation.
/// </summary> /// </summary>
/// <param name="removeIds">用户 Id</param> /// <param name="removeIds">Member list.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPartiallySuccessResult> RemoveMembers(IEnumerable<string> removeIds) { public async Task<LCIMPartiallySuccessResult> RemoveMembers(IEnumerable<string> removeIds) {
if (removeIds == null || removeIds.Count() == 0) { if (removeIds == null || removeIds.Count() == 0) {
@ -234,7 +234,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 加入对话 /// Joins this conversation.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Join() { public async Task Join() {
@ -249,7 +249,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 离开对话 /// Leaves this conversation.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Quit() { public async Task Quit() {
@ -261,9 +261,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 发送消息 /// Sends a message in this conversation.
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message">The message to send.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMMessage> Send(LCIMMessage message, public async Task<LCIMMessage> Send(LCIMMessage message,
LCIMMessageSendOptions options = null) { LCIMMessageSendOptions options = null) {
@ -279,7 +279,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 静音 /// Turns off the offline notifications of this conversation.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Mute() { public async Task Mute() {
@ -288,7 +288,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 取消静音 /// Turns on the offline notifications of this conversation.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Unmute() { public async Task Unmute() {
@ -297,9 +297,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 禁言 /// Mutes members of this conversation.
/// </summary> /// </summary>
/// <param name="clientIds"></param> /// <param name="clientIds">Member list.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPartiallySuccessResult> MuteMembers(IEnumerable<string> clientIds) { public async Task<LCIMPartiallySuccessResult> MuteMembers(IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -313,9 +313,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 取消禁言 /// Unmutes members of this conversation.
/// </summary> /// </summary>
/// <param name="clientIdList"></param> /// <param name="clientIdList">Member list.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPartiallySuccessResult> UnmuteMembers(IEnumerable<string> clientIds) { public async Task<LCIMPartiallySuccessResult> UnmuteMembers(IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -329,9 +329,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 将用户加入黑名单 /// Adds members to the blocklist of this conversation.
/// </summary> /// </summary>
/// <param name="clientIds"></param> /// <param name="clientIds">Member list.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPartiallySuccessResult> BlockMembers(IEnumerable<string> clientIds) { public async Task<LCIMPartiallySuccessResult> BlockMembers(IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -341,9 +341,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 将用户移除黑名单 /// Removes members from the blocklist of this conversation.
/// </summary> /// </summary>
/// <param name="clientIds"></param> /// <param name="clientIds">Member list.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPartiallySuccessResult> UnblockMembers(IEnumerable<string> clientIds) { public async Task<LCIMPartiallySuccessResult> UnblockMembers(IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -353,9 +353,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 撤回消息 /// Recalls a sent message.
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message">The message to recall.</param>
/// <returns></returns> /// <returns></returns>
public async Task RecallMessage(LCIMMessage message) { public async Task RecallMessage(LCIMMessage message) {
if (message == null) { if (message == null) {
@ -365,10 +365,10 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 修改消息 /// Updates a sent message.
/// </summary> /// </summary>
/// <param name="oldMessage"></param> /// <param name="oldMessage">The message to update.</param>
/// <param name="newMessage"></param> /// <param name="newMessage">The updated message.</param>
/// <returns></returns> /// <returns></returns>
public async Task UpdateMessage(LCIMMessage oldMessage, LCIMMessage newMessage) { public async Task UpdateMessage(LCIMMessage oldMessage, LCIMMessage newMessage) {
if (oldMessage == null) { if (oldMessage == null) {
@ -381,10 +381,10 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 更新对话中成员的角色 /// Updates the role of a member of this conversation.
/// </summary> /// </summary>
/// <param name="memberId"></param> /// <param name="memberId">The member to update.</param>
/// <param name="role"></param> /// <param name="role">The new role of the member.</param>
/// <returns></returns> /// <returns></returns>
public async Task UpdateMemberRole(string memberId, string role) { public async Task UpdateMemberRole(string memberId, string role) {
if (string.IsNullOrEmpty(memberId)) { if (string.IsNullOrEmpty(memberId)) {
@ -397,7 +397,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取对话中成员的角色(只返回管理员) /// Gets all member roles.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo() { public async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo() {
@ -405,9 +405,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取对话中指定成员的角色 /// Gets the role of a specific member.
/// </summary> /// </summary>
/// <param name="memberId"></param> /// <param name="memberId">The member to query.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMConversationMemberInfo> GetMemberInfo(string memberId) { public async Task<LCIMConversationMemberInfo> GetMemberInfo(string memberId) {
if (string.IsNullOrEmpty(memberId)) { if (string.IsNullOrEmpty(memberId)) {
@ -423,10 +423,10 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 查询禁言用户 /// Queries muted members.
/// </summary> /// </summary>
/// <param name="limit"></param> /// <param name="limit">Limits the number of returned results.</param>
/// <param name="next"></param> /// <param name="next">Can be used for pagination with the limit parameter.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPageResult> QueryMutedMembers(int limit = 10, public async Task<LCIMPageResult> QueryMutedMembers(int limit = 10,
string next = null) { string next = null) {
@ -434,10 +434,10 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 查询黑名单用户 /// Queries blocked members.
/// </summary> /// </summary>
/// <param name="limit">限制</param> /// <param name="limit">Limits the number of returned results.</param>
/// <param name="next">其实用户 Id</param> /// <param name="next">Can be used for pagination with the limit parameter.</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMPageResult> QueryBlockedMembers(int limit = 10, public async Task<LCIMPageResult> QueryBlockedMembers(int limit = 10,
string next = null) { string next = null) {
@ -445,13 +445,13 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 查询聊天记录 /// Retrieves messages.
/// </summary> /// </summary>
/// <param name="start">起点</param> /// <param name="start">Start message ID.</param>
/// <param name="end">终点</param> /// <param name="end">End message ID.</param>
/// <param name="direction">查找方向</param> /// <param name="direction">Query direction (defaults to NewToOld).</param>
/// <param name="limit">限制</param> /// <param name="limit">Limits the number of returned results. Its default value is 20.</param>
/// <param name="messageType">消息类型</param> /// <param name="messageType">The message type to query. The default value is 0 (text message).</param>
/// <returns></returns> /// <returns></returns>
public async Task<ReadOnlyCollection<LCIMMessage>> QueryMessages(LCIMMessageQueryEndpoint start = null, public async Task<ReadOnlyCollection<LCIMMessage>> QueryMessages(LCIMMessageQueryEndpoint start = null,
LCIMMessageQueryEndpoint end = null, LCIMMessageQueryEndpoint end = null,
@ -462,7 +462,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取会话已收/已读时间戳 /// Fetches receipt timestamp.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task FetchReciptTimestamps() { public async Task FetchReciptTimestamps() {

View File

@ -1,18 +1,9 @@
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
public class LCIMConversationMemberInfo { public class LCIMConversationMemberInfo {
/// <summary>
/// 群主
/// </summary>
public const string Owner = "Owner"; public const string Owner = "Owner";
/// <summary>
/// 管理员
/// </summary>
public const string Manager = "Manager"; public const string Manager = "Manager";
/// <summary>
/// 成员
/// </summary>
public const string Member = "Member"; public const string Member = "Member";
public string ConversationId { public string ConversationId {

View File

@ -17,7 +17,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 等于 /// The value corresponding to key is equal to value, or the array corresponding to key contains value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -29,7 +29,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 不等于 /// The value corresponding to key is not equal to value, or the array corresponding to key does not contain value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -41,7 +41,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 包含 /// Values contains value corresponding to key, or values contains at least one element in the array corresponding to key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -53,7 +53,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 不包含 /// The value of key must not be contained in values.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -65,7 +65,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 包含全部 /// The array corresponding to key contains all elements in values.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -77,7 +77,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 存在 /// The attribute corresponding to key exists.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -87,7 +87,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 不存在 /// The attribute corresponding to key does not exist.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -97,7 +97,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 长度等于 /// The size of the array corresponding to key is equal to size.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="size"></param> /// <param name="size"></param>
@ -109,7 +109,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 大于 /// The value corresponding to key is greater than value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -121,7 +121,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 大于等于 /// The value corresponding to key is greater than or equal to value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -133,7 +133,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 小于 /// The value corresponding to key is less than value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -145,7 +145,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 小于等于 /// The value corresponding to key is less than or equal to value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -157,7 +157,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 前缀 /// The string corresponding to key has a prefix.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="prefix"></param> /// <param name="prefix"></param>
@ -169,7 +169,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 后缀 /// The string corresponding to key has a suffix.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="suffix"></param> /// <param name="suffix"></param>
@ -180,7 +180,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 字符串包含 /// The string corresponding to key has a subString.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="subString"></param> /// <param name="subString"></param>
@ -191,9 +191,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 按 key 升序 /// The ascending order by the value corresponding to key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key">Multi-field sorting is supported with comma.</param>
/// <returns></returns> /// <returns></returns>
public LCIMConversationQuery OrderBy(string key) { public LCIMConversationQuery OrderBy(string key) {
Condition.OrderByAscending(key); Condition.OrderByAscending(key);
@ -201,9 +201,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 按 key 降序 /// The descending order by the value corresponding to key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key">Multi-field sorting is supported with comma.</param>
/// <returns></returns> /// <returns></returns>
public LCIMConversationQuery OrderByDescending(string key) { public LCIMConversationQuery OrderByDescending(string key) {
Condition.OrderByDescending(key); Condition.OrderByDescending(key);
@ -211,7 +211,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 拉取 key 的完整对象 /// Includes nested LCObject for the provided key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -221,7 +221,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 包含 key /// Restricts the keys of the LCObject returned.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -231,7 +231,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 跳过 /// Sets the amount of results to skip before returning any results.
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
@ -241,7 +241,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 限制数量 /// Sets the limit of the number of results to return.
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
@ -255,7 +255,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 查找 /// Retrieves a list of LCObjects matching this query.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<ReadOnlyCollection<LCIMConversation>> Find() { public async Task<ReadOnlyCollection<LCIMConversation>> Find() {

View File

@ -2,9 +2,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 系统对话
/// </summary>
public class LCIMServiceConversation : LCIMConversation { public class LCIMServiceConversation : LCIMConversation {
public LCIMServiceConversation(LCIMClient client) : base(client) { public LCIMServiceConversation(LCIMClient client) : base(client) {
} }

View File

@ -1,20 +1,11 @@
using System; using System;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 临时对话
/// </summary>
public class LCIMTemporaryConversation : LCIMConversation { public class LCIMTemporaryConversation : LCIMConversation {
/// <summary>
/// 过期时间
/// </summary>
public DateTime ExpiredAt { public DateTime ExpiredAt {
get; get;
} }
/// <summary>
/// 是否过期
/// </summary>
public bool IsExpired { public bool IsExpired {
get { get {
return DateTime.Now > ExpiredAt; return DateTime.Now > ExpiredAt;

View File

@ -10,7 +10,7 @@ using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Connection { namespace LeanCloud.Realtime.Internal.Connection {
/// <summary> /// <summary>
/// 连接层,只与数据协议相关 /// Connection layer
/// </summary> /// </summary>
public class LCConnection { public class LCConnection {
// 请求/应答比对,即 I 相等 // 请求/应答比对,即 I 相等
@ -24,53 +24,29 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 连接状态
/// </summary>
enum State { enum State {
/// <summary> /// <summary>
/// 初始状态 /// Initial
/// </summary> /// </summary>
None, None,
/// <summary>
/// 连接中
/// </summary>
Connecting, Connecting,
/// <summary> /// <summary>
/// 连接成功 /// Connected
/// </summary> /// </summary>
Open, Open,
/// <summary>
/// 关闭的
/// </summary>
Closed, Closed,
} }
/// <summary>
/// 发送超时
/// </summary>
private const int SEND_TIMEOUT = 10000; private const int SEND_TIMEOUT = 10000;
/// <summary>
/// 最大重连次数,超过后重置 Router 缓存后再次尝试重连
/// </summary>
private const int MAX_RECONNECT_TIMES = 10; private const int MAX_RECONNECT_TIMES = 10;
/// <summary>
/// 重连间隔
/// </summary>
private const int RECONNECT_INTERVAL = 10000; private const int RECONNECT_INTERVAL = 10000;
/// <summary>
/// 子协议
/// </summary>
private const string SUB_PROTOCOL = "lc.protobuf2.3"; private const string SUB_PROTOCOL = "lc.protobuf2.3";
internal string id; internal string id;
/// <summary>
/// 请求回调缓存
/// </summary>
private readonly Dictionary<GenericCommand, TaskCompletionSource<GenericCommand>> requestToResponses; private readonly Dictionary<GenericCommand, TaskCompletionSource<GenericCommand>> requestToResponses;
private int requestI = 1; private int requestI = 1;
@ -134,11 +110,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 发送请求,会在收到应答后返回
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
internal async Task<GenericCommand> SendRequest(GenericCommand request) { internal async Task<GenericCommand> SendRequest(GenericCommand request) {
if (IsIdempotentCommand(request)) { if (IsIdempotentCommand(request)) {
GenericCommand sendingReq = requestToResponses.Keys.FirstOrDefault(item => { GenericCommand sendingReq = requestToResponses.Keys.FirstOrDefault(item => {
@ -166,11 +137,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
return await tcs.Task; return await tcs.Task;
} }
/// <summary>
/// 发送命令
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
internal async Task SendCommand(GenericCommand command) { internal async Task SendCommand(GenericCommand command) {
LCLogger.Debug($"{id} => {FormatCommand(command)}"); LCLogger.Debug($"{id} => {FormatCommand(command)}");
byte[] bytes = command.ToByteArray(); byte[] bytes = command.ToByteArray();
@ -182,9 +148,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 断开连接
/// </summary>
private void Disconnect() { private void Disconnect() {
state = State.Closed; state = State.Closed;
heartBeat.Stop(); heartBeat.Stop();
@ -194,10 +157,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 消息接收回调
/// </summary>
/// <param name="bytes"></param>
private void OnMessage(byte[] bytes) { private void OnMessage(byte[] bytes) {
try { try {
GenericCommand command = GenericCommand.Parser.ParseFrom(bytes); GenericCommand command = GenericCommand.Parser.ParseFrom(bytes);
@ -241,18 +200,11 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 连接断开回调
/// </summary>
private void OnDisconnect() { private void OnDisconnect() {
Disconnect(); Disconnect();
_ = Reconnect(); _ = Reconnect();
} }
/// <summary>
/// 重置连接
/// </summary>
/// <returns></returns>
internal void Reset() { internal void Reset() {
Disconnect(); Disconnect();
// 重新创建连接组件 // 重新创建连接组件
@ -318,16 +270,10 @@ namespace LeanCloud.Realtime.Internal.Connection {
} }
} }
/// <summary>
/// 暂停连接
/// </summary>
internal void Pause() { internal void Pause() {
Disconnect(); Disconnect();
} }
/// <summary>
/// 恢复连接
/// </summary>
internal void Resume() { internal void Resume() {
_ = Reconnect(); _ = Reconnect();
} }

View File

@ -5,10 +5,11 @@ using LeanCloud.Realtime.Internal.Protocol;
namespace LeanCloud.Realtime.Internal.Connection { namespace LeanCloud.Realtime.Internal.Connection {
/// <summary> /// <summary>
/// 心跳控制器,由于 .Net Standard 2.0 不支持发送 ping frame所以需要发送逻辑心跳 /// Heartbeat controller is needed because .Net Standard 2.0 does not support sending ping frame.
/// 1. 每隔 180s 发送 ping 包 /// 1. Ping every 180 seconds.
/// 2. 接收到 pong 包刷新上次 pong 时间 /// 2. Receiving a pong packet will refresh the pong interval.
/// 3. 每隔 180s 检测 pong 包间隔,超过 360s 则认为断开 /// 3. Check pong interval every 180 seconds.
/// If the interval is greater than 360 seconds, the connection is considered disconnected.
/// </summary> /// </summary>
public class LCHeartBeat { public class LCHeartBeat {
private const int PING_INTERVAL = 180 * 1000; private const int PING_INTERVAL = 180 * 1000;
@ -32,9 +33,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
this.connection = connection; this.connection = connection;
} }
/// <summary>
/// 启动心跳
/// </summary>
public void Start() { public void Start() {
running = true; running = true;
heartBeatCTS = new CancellationTokenSource(); heartBeatCTS = new CancellationTokenSource();
@ -92,9 +90,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
lastPongTime = DateTimeOffset.Now; lastPongTime = DateTimeOffset.Now;
} }
/// <summary>
/// 停止心跳监听
/// </summary>
public void Stop() { public void Stop() {
running = false; running = false;
heartBeatCTS.Cancel(); heartBeatCTS.Cancel();

View File

@ -16,17 +16,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
#region 内部接口 #region 内部接口
/// <summary>
/// 创建对话
/// </summary>
/// <param name="members"></param>
/// <param name="name"></param>
/// <param name="transient"></param>
/// <param name="unique"></param>
/// <param name="temporary"></param>
/// <param name="temporaryTtl"></param>
/// <param name="properties"></param>
/// <returns></returns>
internal async Task<LCIMConversation> CreateConv( internal async Task<LCIMConversation> CreateConv(
IEnumerable<string> members = null, IEnumerable<string> members = null,
string name = null, string name = null,
@ -94,11 +83,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return conversation; return conversation;
} }
/// <summary>
/// 查询成员数量
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task<int> GetMembersCount(string convId) { internal async Task<int> GetMembersCount(string convId) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
Cid = convId, Cid = convId,
@ -109,12 +94,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return response.ConvMessage.Count; return response.ConvMessage.Count;
} }
/// <summary>
/// 更新对话属性
/// </summary>
/// <param name="convId"></param>
/// <param name="attributes"></param>
/// <returns></returns>
internal async Task<Dictionary<string, object>> UpdateInfo(string convId, internal async Task<Dictionary<string, object>> UpdateInfo(string convId,
Dictionary<string, object> attributes) { Dictionary<string, object> attributes) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
@ -135,12 +115,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return null; return null;
} }
/// <summary>
/// 增加成员
/// </summary>
/// <param name="convId"></param>
/// <param name="clientIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> AddMembers(string convId, internal async Task<LCIMPartiallySuccessResult> AddMembers(string convId,
IEnumerable<string> clientIds) { IEnumerable<string> clientIds) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
@ -165,12 +140,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(allowedIds, errors); return NewPartiallySuccessResult(allowedIds, errors);
} }
/// <summary>
/// 移除成员
/// </summary>
/// <param name="convId"></param>
/// <param name="removeIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> RemoveMembers(string convId, internal async Task<LCIMPartiallySuccessResult> RemoveMembers(string convId,
IEnumerable<string> removeIds) { IEnumerable<string> removeIds) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
@ -195,11 +165,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(allowedIds, errors); return NewPartiallySuccessResult(allowedIds, errors);
} }
/// <summary>
/// 静音
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task Mute(string convId) { internal async Task Mute(string convId) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
Cid = convId Cid = convId
@ -209,11 +175,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
await Connection.SendRequest(request); await Connection.SendRequest(request);
} }
/// <summary>
/// 解除静音
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task Unmute(string convId) { internal async Task Unmute(string convId) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
Cid = convId Cid = convId
@ -223,12 +184,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
await Connection.SendRequest(request); await Connection.SendRequest(request);
} }
/// <summary>
/// 禁言用户
/// </summary>
/// <param name="convId"></param>
/// <param name="clientIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> MuteMembers(string convId, internal async Task<LCIMPartiallySuccessResult> MuteMembers(string convId,
IEnumerable<string> clientIds) { IEnumerable<string> clientIds) {
if (clientIds == null || clientIds.Count() == 0) { if (clientIds == null || clientIds.Count() == 0) {
@ -244,12 +199,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(response.ConvMessage.AllowedPids, response.ConvMessage.FailedPids); return NewPartiallySuccessResult(response.ConvMessage.AllowedPids, response.ConvMessage.FailedPids);
} }
/// <summary>
/// 解除用户禁言
/// </summary>
/// <param name="convId"></param>
/// <param name="clientIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> UnmuteMembers(string convId, internal async Task<LCIMPartiallySuccessResult> UnmuteMembers(string convId,
IEnumerable<string> clientIds) { IEnumerable<string> clientIds) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
@ -262,12 +212,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(response.ConvMessage.AllowedPids, response.ConvMessage.FailedPids); return NewPartiallySuccessResult(response.ConvMessage.AllowedPids, response.ConvMessage.FailedPids);
} }
/// <summary>
/// 拉黑成员
/// </summary>
/// <param name="convId"></param>
/// <param name="clientIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> BlockMembers(string convId, internal async Task<LCIMPartiallySuccessResult> BlockMembers(string convId,
IEnumerable<string> clientIds) { IEnumerable<string> clientIds) {
BlacklistCommand blacklist = new BlacklistCommand { BlacklistCommand blacklist = new BlacklistCommand {
@ -289,12 +234,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(response.BlacklistMessage.AllowedPids, response.BlacklistMessage.FailedPids); return NewPartiallySuccessResult(response.BlacklistMessage.AllowedPids, response.BlacklistMessage.FailedPids);
} }
/// <summary>
/// 移除成员黑名单
/// </summary>
/// <param name="convId"></param>
/// <param name="clientIds"></param>
/// <returns></returns>
internal async Task<LCIMPartiallySuccessResult> UnblockMembers(string convId, internal async Task<LCIMPartiallySuccessResult> UnblockMembers(string convId,
IEnumerable<string> clientIds) { IEnumerable<string> clientIds) {
BlacklistCommand blacklist = new BlacklistCommand { BlacklistCommand blacklist = new BlacklistCommand {
@ -316,13 +256,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return NewPartiallySuccessResult(response.BlacklistMessage.AllowedPids, response.BlacklistMessage.FailedPids); return NewPartiallySuccessResult(response.BlacklistMessage.AllowedPids, response.BlacklistMessage.FailedPids);
} }
/// <summary>
/// 修改成员角色
/// </summary>
/// <param name="convId"></param>
/// <param name="memberId"></param>
/// <param name="role"></param>
/// <returns></returns>
internal async Task UpdateMemberRole(string convId, internal async Task UpdateMemberRole(string convId,
string memberId, string memberId,
string role) { string role) {
@ -339,11 +273,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
GenericCommand response = await Connection.SendRequest(request); GenericCommand response = await Connection.SendRequest(request);
} }
/// <summary>
/// 获取所有成员角色
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo(string convId) { internal async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo(string convId) {
string path = "classes/_ConversationMemberInfo"; string path = "classes/_ConversationMemberInfo";
string token = await Client.SessionController.GetToken(); string token = await Client.SessionController.GetToken();
@ -367,13 +297,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
}).ToList().AsReadOnly(); }).ToList().AsReadOnly();
} }
/// <summary>
/// 查询禁言成员
/// </summary>
/// <param name="convId"></param>
/// <param name="limit"></param>
/// <param name="next"></param>
/// <returns></returns>
internal async Task<LCIMPageResult> QueryMutedMembers(string convId, internal async Task<LCIMPageResult> QueryMutedMembers(string convId,
int limit = 10, int limit = 10,
string next = null) { string next = null) {
@ -393,13 +317,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
}; };
} }
/// <summary>
/// 查询黑名单用户
/// </summary>
/// <param name="convId"></param>
/// <param name="limit"></param>
/// <param name="next"></param>
/// <returns></returns>
internal async Task<LCIMPageResult> QueryBlockedMembers(string convId, internal async Task<LCIMPageResult> QueryBlockedMembers(string convId,
int limit = 10, int limit = 10,
string next = null) { string next = null) {
@ -419,11 +336,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
}; };
} }
/// <summary>
/// 查找
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
internal async Task<ReadOnlyCollection<LCIMConversation>> Find(LCIMConversationQuery query) { internal async Task<ReadOnlyCollection<LCIMConversation>> Find(LCIMConversationQuery query) {
GenericCommand command = new GenericCommand { GenericCommand command = new GenericCommand {
Cmd = CommandType.Conv, Cmd = CommandType.Conv,
@ -468,11 +381,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
}).ToList().AsReadOnly(); }).ToList().AsReadOnly();
} }
/// <summary>
/// 获取临时对话
/// </summary>
/// <param name="convIds"></param>
/// <returns></returns>
internal async Task<List<LCIMTemporaryConversation>> GetTemporaryConversations(IEnumerable<string> convIds) { internal async Task<List<LCIMTemporaryConversation>> GetTemporaryConversations(IEnumerable<string> convIds) {
if (convIds == null || convIds.Count() == 0) { if (convIds == null || convIds.Count() == 0) {
return null; return null;
@ -493,11 +402,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return convList; return convList;
} }
/// <summary>
/// 拉取对话接收/已读情况
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task FetchReciptTimestamp(string convId) { internal async Task FetchReciptTimestamp(string convId) {
ConvCommand convCommand = new ConvCommand { ConvCommand convCommand = new ConvCommand {
Cid = convId Cid = convId
@ -511,12 +416,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
conversation.LastReadTimestamp = convCommand.MaxReadTimestamp; conversation.LastReadTimestamp = convCommand.MaxReadTimestamp;
} }
/// <summary>
/// 获取在线成员
/// </summary>
/// <param name="convId"></param>
/// <param name="limit"></param>
/// <returns></returns>
internal async Task<ReadOnlyCollection<string>> GetOnlineMembers(string convId, internal async Task<ReadOnlyCollection<string>> GetOnlineMembers(string convId,
int limit) { int limit) {
ConvCommand conv = new ConvCommand { ConvCommand conv = new ConvCommand {
@ -531,11 +431,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return members; return members;
} }
/// <summary>
/// 查询是否订阅
/// </summary>
/// <param name="convId"></param>
/// <returns></returns>
internal async Task<bool> CheckSubscription(string convId) { internal async Task<bool> CheckSubscription(string convId) {
ConvCommand conv = new ConvCommand(); ConvCommand conv = new ConvCommand();
conv.Cids.Add(convId); conv.Cids.Add(convId);
@ -666,21 +562,13 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
} }
/// <summary>
/// 当前用户加入会话
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnJoined(ConvCommand convMessage) { private async Task OnJoined(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
Client.OnInvited?.Invoke(conversation, convMessage.InitBy); Client.OnInvited?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 有用户加入会话
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMembersJoined(ConvCommand convMessage) { private async Task OnMembersJoined(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> joinedIds = new ReadOnlyCollection<string>(convMessage.M); ReadOnlyCollection<string> joinedIds = new ReadOnlyCollection<string>(convMessage.M);
@ -688,11 +576,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnMembersJoined?.Invoke(conversation, joinedIds, convMessage.InitBy); Client.OnMembersJoined?.Invoke(conversation, joinedIds, convMessage.InitBy);
} }
/// <summary>
/// 当前用户离开会话
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnLeft(ConvCommand convMessage) { private async Task OnLeft(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
// 从内存中清除对话 // 从内存中清除对话
@ -700,11 +584,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnKicked?.Invoke(conversation, convMessage.InitBy); Client.OnKicked?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 有成员离开会话
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMemberLeft(ConvCommand convMessage) { private async Task OnMemberLeft(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> leftIdList = new ReadOnlyCollection<string>(convMessage.M); ReadOnlyCollection<string> leftIdList = new ReadOnlyCollection<string>(convMessage.M);
@ -712,31 +591,19 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnMembersLeft?.Invoke(conversation, leftIdList, convMessage.InitBy); Client.OnMembersLeft?.Invoke(conversation, leftIdList, convMessage.InitBy);
} }
/// <summary>
/// 当前用户被禁言
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMuted(ConvCommand convMessage) { private async Task OnMuted(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
Client.OnMuted?.Invoke(conversation, convMessage.InitBy); Client.OnMuted?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 当前用户被解除禁言
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnUnmuted(ConvCommand convMessage) { private async Task OnUnmuted(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
Client.OnUnmuted?.Invoke(conversation, convMessage.InitBy); Client.OnUnmuted?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 有成员被禁言
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMembersMuted(ConvCommand convMessage) { private async Task OnMembersMuted(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> mutedMemberIds = new ReadOnlyCollection<string>(convMessage.M); ReadOnlyCollection<string> mutedMemberIds = new ReadOnlyCollection<string>(convMessage.M);
@ -744,11 +611,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnMembersMuted?.Invoke(conversation, mutedMemberIds, convMessage.InitBy); Client.OnMembersMuted?.Invoke(conversation, mutedMemberIds, convMessage.InitBy);
} }
/// <summary>
/// 有成员被解除禁言
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMembersUnmuted(ConvCommand convMessage) { private async Task OnMembersUnmuted(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> unmutedMemberIds = new ReadOnlyCollection<string>(convMessage.M); ReadOnlyCollection<string> unmutedMemberIds = new ReadOnlyCollection<string>(convMessage.M);
@ -756,53 +619,31 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnMembersUnmuted?.Invoke(conversation, unmutedMemberIds, convMessage.InitBy); Client.OnMembersUnmuted?.Invoke(conversation, unmutedMemberIds, convMessage.InitBy);
} }
/// <summary>
/// 当前用户被拉黑
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnBlocked(ConvCommand convMessage) { private async Task OnBlocked(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
Client.OnBlocked?.Invoke(conversation, convMessage.InitBy); Client.OnBlocked?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 当前用户被解除黑名单
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnUnblocked(ConvCommand convMessage) { private async Task OnUnblocked(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
Client.OnUnblocked?.Invoke(conversation, convMessage.InitBy); Client.OnUnblocked?.Invoke(conversation, convMessage.InitBy);
} }
/// <summary>
/// 有用户被拉黑
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMembersBlocked(ConvCommand convMessage) { private async Task OnMembersBlocked(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> blockedMemberIds = convMessage.M.ToList().AsReadOnly(); ReadOnlyCollection<string> blockedMemberIds = convMessage.M.ToList().AsReadOnly();
Client.OnMembersBlocked?.Invoke(conversation, blockedMemberIds, convMessage.InitBy); Client.OnMembersBlocked?.Invoke(conversation, blockedMemberIds, convMessage.InitBy);
} }
/// <summary>
/// 有用户被移除黑名单
/// </summary>
/// <param name="convMessage"></param>
/// <returns></returns>
private async Task OnMembersUnblocked(ConvCommand convMessage) { private async Task OnMembersUnblocked(ConvCommand convMessage) {
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
ReadOnlyCollection<string> unblockedMemberIds = convMessage.M.ToList().AsReadOnly(); ReadOnlyCollection<string> unblockedMemberIds = convMessage.M.ToList().AsReadOnly();
Client.OnMembersUnblocked?.Invoke(conversation, unblockedMemberIds, convMessage.InitBy); Client.OnMembersUnblocked?.Invoke(conversation, unblockedMemberIds, convMessage.InitBy);
} }
/// <summary>
/// 对话属性被修改
/// </summary>
/// <param name="conv"></param>
/// <returns></returns>
private async Task OnPropertiesUpdated(ConvCommand conv) { private async Task OnPropertiesUpdated(ConvCommand conv) {
LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid);
Dictionary<string, object> updatedAttr = JsonConvert.DeserializeObject<Dictionary<string, object>>(conv.AttrModified.Data, Dictionary<string, object> updatedAttr = JsonConvert.DeserializeObject<Dictionary<string, object>>(conv.AttrModified.Data,
@ -814,11 +655,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
conv.InitBy); conv.InitBy);
} }
/// <summary>
/// 用户角色被修改
/// </summary>
/// <param name="conv"></param>
/// <returns></returns>
private async Task OnMemberInfoChanged(ConvCommand conv) { private async Task OnMemberInfoChanged(ConvCommand conv) {
LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid); LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid);
ConvMemberInfo memberInfo = conv.Info; ConvMemberInfo memberInfo = conv.Info;

View File

@ -14,12 +14,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
#region 内部接口 #region 内部接口
/// <summary>
/// 发送消息
/// </summary>
/// <param name="convId"></param>
/// <param name="message"></param>
/// <returns></returns>
internal async Task<LCIMMessage> Send(string convId, internal async Task<LCIMMessage> Send(string convId,
LCIMMessage message, LCIMMessage message,
LCIMMessageSendOptions options) { LCIMMessageSendOptions options) {
@ -74,12 +69,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
return message; return message;
} }
/// <summary>
/// 撤回消息
/// </summary>
/// <param name="convId"></param>
/// <param name="message"></param>
/// <returns></returns>
internal async Task RecallMessage(string convId, internal async Task RecallMessage(string convId,
LCIMMessage message) { LCIMMessage message) {
PatchCommand patch = new PatchCommand(); PatchCommand patch = new PatchCommand();
@ -97,13 +87,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
await Connection.SendRequest(request); await Connection.SendRequest(request);
} }
/// <summary>
/// 修改消息
/// </summary>
/// <param name="convId"></param>
/// <param name="oldMessage"></param>
/// <param name="newMessage"></param>
/// <returns></returns>
internal async Task UpdateMessage(string convId, internal async Task UpdateMessage(string convId,
LCIMMessage oldMessage, LCIMMessage oldMessage,
LCIMMessage newMessage) { LCIMMessage newMessage) {
@ -133,16 +116,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
GenericCommand response = await Connection.SendRequest(request); GenericCommand response = await Connection.SendRequest(request);
} }
/// <summary>
/// 查询消息
/// </summary>
/// <param name="convId"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="direction"></param>
/// <param name="limit"></param>
/// <param name="messageType"></param>
/// <returns></returns>
internal async Task<ReadOnlyCollection<LCIMMessage>> QueryMessages(string convId, internal async Task<ReadOnlyCollection<LCIMMessage>> QueryMessages(string convId,
LCIMMessageQueryEndpoint start = null, LCIMMessageQueryEndpoint start = null,
LCIMMessageQueryEndpoint end = null, LCIMMessageQueryEndpoint end = null,
@ -197,12 +170,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
}).ToList().AsReadOnly(); }).ToList().AsReadOnly();
} }
/// <summary>
/// 确认收到消息
/// </summary>
/// <param name="convId"></param>
/// <param name="msgId"></param>
/// <returns></returns>
internal async Task Ack(string convId, internal async Task Ack(string convId,
string msgId) { string msgId) {
AckCommand ack = new AckCommand { AckCommand ack = new AckCommand {
@ -214,12 +182,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
await Connection.SendCommand(command); await Connection.SendCommand(command);
} }
/// <summary>
/// 确认已读消息
/// </summary>
/// <param name="convId"></param>
/// <param name="msg"></param>
/// <returns></returns>
internal async Task Read(string convId, internal async Task Read(string convId,
LCIMMessage msg) { LCIMMessage msg) {
ReadCommand read = new ReadCommand(); ReadCommand read = new ReadCommand();
@ -248,11 +210,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
} }
/// <summary>
/// 接收消息事件
/// </summary>
/// <param name="notification"></param>
/// <returns></returns>
private async Task OnMessaage(GenericCommand notification) { private async Task OnMessaage(GenericCommand notification) {
DirectCommand direct = notification.DirectMessage; DirectCommand direct = notification.DirectMessage;
// 反序列化消息 // 反序列化消息
@ -288,11 +246,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
Client.OnMessage?.Invoke(conversation, message); Client.OnMessage?.Invoke(conversation, message);
} }
/// <summary>
/// 消息被修改事件
/// </summary>
/// <param name="notification"></param>
/// <returns></returns>
private async Task OnMessagePatched(GenericCommand notification) { private async Task OnMessagePatched(GenericCommand notification) {
PatchCommand patchMessage = notification.PatchMessage; PatchCommand patchMessage = notification.PatchMessage;
foreach (PatchItem patch in patchMessage.Patches) { foreach (PatchItem patch in patchMessage.Patches) {
@ -320,11 +274,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
} }
/// <summary>
/// 消息回执事件
/// </summary>
/// <param name="notification"></param>
/// <returns></returns>
private async Task OnMessageReceipt(GenericCommand notification) { private async Task OnMessageReceipt(GenericCommand notification) {
RcpCommand rcp = notification.RcpMessage; RcpCommand rcp = notification.RcpMessage;
string convId = rcp.Cid; string convId = rcp.Cid;

View File

@ -15,10 +15,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
#region 内部接口 #region 内部接口
/// <summary>
/// 打开会话
/// </summary>
/// <returns></returns>
internal async Task Open(bool force) { internal async Task Open(bool force) {
await Connection.Connect(); await Connection.Connect();
@ -32,10 +29,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
Connection.Register(Client); Connection.Register(Client);
} }
/// <summary>
/// 重新打开会话,重连时调用
/// </summary>
/// <returns></returns>
internal async Task Reopen() { internal async Task Reopen() {
SessionCommand session = await NewSessionCommand(); SessionCommand session = await NewSessionCommand();
session.R = true; session.R = true;
@ -49,20 +42,14 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
} }
/// <summary>
/// 关闭会话
/// </summary>
/// <returns></returns>
internal async Task Close() { internal async Task Close() {
GenericCommand request = NewCommand(CommandType.Session, OpType.Close); GenericCommand request = NewCommand(CommandType.Session, OpType.Close);
await Connection.SendRequest(request); await Connection.SendRequest(request);
Connection.UnRegister(Client); Connection.UnRegister(Client);
} }
/// <summary>
/// 获取可用 token
/// </summary>
/// <returns></returns>
internal async Task<string> GetToken() { internal async Task<string> GetToken() {
if (IsExpired) { if (IsExpired) {
await Refresh(); await Refresh();
@ -134,11 +121,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
} }
} }
/// <summary>
/// 被关闭
/// </summary>
/// <param name="session"></param>
/// <returns></returns>
private void OnClosed(SessionCommand session) { private void OnClosed(SessionCommand session) {
int code = session.Code; int code = session.Code;
string reason = session.Reason; string reason = session.Reason;

View File

@ -5,13 +5,8 @@ using LeanCloud.Common;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace LeanCloud.Realtime.Internal.Router { namespace LeanCloud.Realtime.Internal.Router {
/// <summary>
/// RTM Router
/// </summary>
public class LCRTMRouter { public class LCRTMRouter {
/// <summary>
/// 请求超时
/// </summary>
private const int REQUEST_TIMEOUT = 10000; private const int REQUEST_TIMEOUT = 10000;
private LCRTMServer rtmServer; private LCRTMServer rtmServer;
@ -19,10 +14,6 @@ namespace LeanCloud.Realtime.Internal.Router {
public LCRTMRouter() { public LCRTMRouter() {
} }
/// <summary>
/// 获取服务器地址
/// </summary>
/// <returns></returns>
public async Task<LCRTMServer> GetServer() { public async Task<LCRTMServer> GetServer() {
if (rtmServer == null || !rtmServer.IsValid) { if (rtmServer == null || !rtmServer.IsValid) {
await Fetch(); await Fetch();

View File

@ -4,40 +4,20 @@ using System.Net.WebSockets;
using System.Text; using System.Text;
namespace LeanCloud.Realtime.Internal.WebSocket { namespace LeanCloud.Realtime.Internal.WebSocket {
/// <summary>
/// WebSocket 客户端,负责底层连接和事件,只与通信协议相关
/// </summary>
public class LCWebSocketClient { public class LCWebSocketClient {
// .net standard 2.0 好像在拼合 Frame 时有 bug所以将这个值调整大一些 // .net standard 2.0 好像在拼合 Frame 时有 bug所以将这个值调整大一些
private const int RECV_BUFFER_SIZE = 1024 * 5; private const int RECV_BUFFER_SIZE = 1024 * 5;
/// <summary>
/// 关闭超时
/// </summary>
private const int CLOSE_TIMEOUT = 5000; private const int CLOSE_TIMEOUT = 5000;
/// <summary>
/// 连接超时
/// </summary>
private const int CONNECT_TIMEOUT = 10000; private const int CONNECT_TIMEOUT = 10000;
/// <summary>
/// 消息事件
/// </summary>
public Action<byte[]> OnMessage; public Action<byte[]> OnMessage;
/// <summary>
/// 连接关闭
/// </summary>
public Action OnClose; public Action OnClose;
private ClientWebSocket ws; private ClientWebSocket ws;
/// <summary>
/// 连接指定 ws 服务器
/// </summary>
/// <param name="server"></param>
/// <returns></returns>
public async Task Connect(string server, public async Task Connect(string server,
string subProtocol = null) { string subProtocol = null) {
LCLogger.Debug($"Connecting WebSocket: {server}"); LCLogger.Debug($"Connecting WebSocket: {server}");
@ -57,10 +37,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
} }
} }
/// <summary>
/// 主动关闭连接
/// </summary>
/// <returns></returns>
public async Task Close() { public async Task Close() {
LCLogger.Debug("Closing WebSocket"); LCLogger.Debug("Closing WebSocket");
OnMessage = null; OnMessage = null;
@ -80,11 +56,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
} }
} }
/// <summary>
/// 发送二进制数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task Send(byte[] data, public async Task Send(byte[] data,
WebSocketMessageType messageType = WebSocketMessageType.Binary) { WebSocketMessageType messageType = WebSocketMessageType.Binary) {
ArraySegment<byte> bytes = new ArraySegment<byte>(data); ArraySegment<byte> bytes = new ArraySegment<byte>(data);
@ -102,19 +73,10 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
} }
} }
/// <summary>
/// 发送文本数据
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public async Task Send(string text) { public async Task Send(string text) {
await Send(Encoding.UTF8.GetBytes(text), WebSocketMessageType.Text); await Send(Encoding.UTF8.GetBytes(text), WebSocketMessageType.Text);
} }
/// <summary>
/// 接收数据
/// </summary>
/// <returns></returns>
private async Task StartReceive() { private async Task StartReceive() {
byte[] buffer = new byte[RECV_BUFFER_SIZE]; byte[] buffer = new byte[RECV_BUFFER_SIZE];
try { try {

View File

@ -8,39 +8,31 @@ using LeanCloud.Realtime.Internal.Protocol;
using LeanCloud.Realtime.Internal.Controller; using LeanCloud.Realtime.Internal.Controller;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 通信客户端
/// </summary>
public class LCIMClient { public class LCIMClient {
/// <summary> /// <summary>
/// 对话缓存 /// Conversation cache
/// </summary> /// </summary>
internal Dictionary<string, LCIMConversation> ConversationDict; internal Dictionary<string, LCIMConversation> ConversationDict;
/// <summary> /// <summary>
/// 用户 Id /// Client Id
/// </summary> /// </summary>
public string Id { public string Id {
get; private set; get; private set;
} }
/// <summary> /// <summary>
/// 用户标识 /// Client tag
/// </summary> /// </summary>
public string Tag { public string Tag {
get; private set; get; private set;
} }
/// <summary>
/// 设备 Id
/// </summary>
public string DeviceId { public string DeviceId {
get; private set; get; private set;
} }
/// <summary>
/// 登录 tokens
/// </summary>
internal string SessionToken { internal string SessionToken {
get; private set; get; private set;
} }
@ -50,21 +42,22 @@ namespace LeanCloud.Realtime {
#region 连接状态事件 #region 连接状态事件
/// <summary> /// <summary>
/// 客户端连接断开 /// Occurs when the connection is lost.
/// </summary> /// </summary>
public Action OnPaused { public Action OnPaused {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 客户端连接恢复正常 /// Occurs when the connection is recovered.
/// </summary> /// </summary>
public Action OnResume { public Action OnResume {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 当前客户端被服务端强行下线 /// Occurs when the connection is closed and there will be no auto reconnection.
/// Possible causes include there is a single device login conflict or the client has been kicked off by the server.
/// </summary> /// </summary>
public Action<int, string> OnClose { public Action<int, string> OnClose {
get; set; get; set;
@ -75,92 +68,92 @@ namespace LeanCloud.Realtime {
#region 对话事件 #region 对话事件
/// <summary> /// <summary>
/// 当前用户被加入某个对话的黑名单 /// Occurs when the current user is added into the blacklist of a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnBlocked { public Action<LCIMConversation, string> OnBlocked {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 当用户被解除黑名单 /// Occurs when the current user is removed from the blacklist of a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnUnblocked { public Action<LCIMConversation, string> OnUnblocked {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 当前用户在某个对话中被禁言 /// Occurs when the current user is muted in a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnMuted; public Action<LCIMConversation, string> OnMuted;
/// <summary> /// <summary>
/// 当前用户在某个对话中被解除禁言 /// Occurs when the current user is unmuted in a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnUnmuted; public Action<LCIMConversation, string> OnUnmuted;
/// <summary> /// <summary>
/// 该对话信息被更新 /// Occurs when the properties of a conversation are updated.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyDictionary<string, object>, string> OnConversationInfoUpdated; public Action<LCIMConversation, ReadOnlyDictionary<string, object>, string> OnConversationInfoUpdated;
/// <summary> /// <summary>
/// 当前用户被添加至某个对话 /// Occurs when the current user is invited to a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnInvited { public Action<LCIMConversation, string> OnInvited {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 当前用户被从某个对话中移除 /// Occurs when the current user is kicked from a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnKicked { public Action<LCIMConversation, string> OnKicked {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有用户被添加至某个对话 /// Occurs when a user joined a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersJoined { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersJoined {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员被从某个对话中移除 /// Occurs when a user left a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersLeft { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersLeft {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员被加入某个对话的黑名单 /// Occurs when a user is added to the blacklist of a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersBlocked { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersBlocked {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员被移出某个对话的黑名单 /// Occurs when a user is removed from the blacklist of a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnblocked { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnblocked {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员在某个对话中被禁言 /// Occurs when a user is muted in a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersMuted { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersMuted {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员被移出某个对话的黑名单 /// Occurs when a user is unmuted in a conversation.
/// </summary> /// </summary>
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnmuted { public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnmuted {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 有成员的对话信息被更新 /// Occurs when the properties of someone are updated.
/// </summary> /// </summary>
public Action<LCIMConversation, string, string, string> OnMemberInfoUpdated; public Action<LCIMConversation, string, string, string> OnMemberInfoUpdated;
@ -169,56 +162,56 @@ namespace LeanCloud.Realtime {
#region 消息事件 #region 消息事件
/// <summary> /// <summary>
/// 当前用户收到消息 /// Occurs when a new message is delivered to a conversation the current user is already in.
/// </summary> /// </summary>
public Action<LCIMConversation, LCIMMessage> OnMessage { public Action<LCIMConversation, LCIMMessage> OnMessage {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息被撤回 /// Occurs when a message is recalled.
/// </summary> /// </summary>
public Action<LCIMConversation, LCIMRecalledMessage> OnMessageRecalled { public Action<LCIMConversation, LCIMRecalledMessage> OnMessageRecalled {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息被修改 /// Occurs when a message is updated.
/// </summary> /// </summary>
public Action<LCIMConversation, LCIMMessage> OnMessageUpdated { public Action<LCIMConversation, LCIMMessage> OnMessageUpdated {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息已送达 /// Occurs when a message is delivered.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnMessageDelivered { public Action<LCIMConversation, string> OnMessageDelivered {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息已读 /// Occurs when a message is read.
/// </summary> /// </summary>
public Action<LCIMConversation, string> OnMessageRead { public Action<LCIMConversation, string> OnMessageRead {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 未读消息数目更新 /// Occurs when the number of unreadMessagesCount is updatded.
/// </summary> /// </summary>
public Action<ReadOnlyCollection<LCIMConversation>> OnUnreadMessagesCountUpdated { public Action<ReadOnlyCollection<LCIMConversation>> OnUnreadMessagesCountUpdated {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 最近分发消息更新 /// Occurs when the last delivered message is updated.
/// </summary> /// </summary>
public Action OnLastDeliveredAtUpdated { public Action OnLastDeliveredAtUpdated {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 最近已读消息更新 /// Occurs when the last delivered message is updated.
/// </summary> /// </summary>
public Action OnLastReadAtUpdated { public Action OnLastReadAtUpdated {
get; set; get; set;
@ -289,9 +282,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 登录 /// Signing in
/// </summary> /// </summary>
/// <param name="force">是否强制登录</param> /// <param name="force">If this is ture (default value), and single device sign-on is enabled, users already logged in on another device with the same tag will be logged out.</param>
/// <returns></returns> /// <returns></returns>
public async Task Open(bool force = true) { public async Task Open(bool force = true) {
try { try {
@ -305,7 +298,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 关闭 /// Closes the session
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Close() { public async Task Close() {
@ -314,12 +307,14 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 创建普通对话 /// Creates a conversation
/// </summary> /// </summary>
/// <param name="members"></param> /// <param name="members">The list of clientIds of participants in this conversation (except the creator)</param>
/// <param name="name"></param> /// <param name="name">The name of this conversation</param>
/// <param name="unique"></param> /// <param name="unique">Whether this conversation is unique;
/// <param name="properties"></param> /// if it is true and an existing conversation contains the same composition of members,
/// the existing conversation will be reused, otherwise a new conversation will be created.</param>
/// <param name="properties">Custom attributes of this conversation</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMConversation> CreateConversation( public async Task<LCIMConversation> CreateConversation(
IEnumerable<string> members, IEnumerable<string> members,
@ -333,10 +328,10 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 创建聊天室 /// Creates a chatroom
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name">The name of this chatroom</param>
/// <param name="properties"></param> /// <param name="properties">Custom attributes of this chatroom</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMChatRoom> CreateChatRoom( public async Task<LCIMChatRoom> CreateChatRoom(
string name, string name,
@ -348,11 +343,11 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 创建临时对话 /// Creates a temporary conversation
/// </summary> /// </summary>
/// <param name="members"></param> /// <param name="members">The list of clientIds of participants in this temporary conversation (except the creator)</param>
/// <param name="ttl"></param> /// <param name="ttl">TTL of this temporary conversation</param>
/// <param name="properties"></param> /// <param name="properties">Custom attributes of this temporary conversation</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMTemporaryConversation> CreateTemporaryConversation( public async Task<LCIMTemporaryConversation> CreateTemporaryConversation(
IEnumerable<string> members, IEnumerable<string> members,
@ -366,9 +361,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 根据 id 获取对话 /// Queries a conversation based on its id.
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id">objectId</param>
/// <returns></returns> /// <returns></returns>
public async Task<LCIMConversation> GetConversation(string id) { public async Task<LCIMConversation> GetConversation(string id) {
if (string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(id)) {
@ -392,9 +387,9 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取某些特定的对话 /// Queries conversations based on their ids.
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="ids">objectId list</param>
/// <returns></returns> /// <returns></returns>
public async Task<ReadOnlyCollection<LCIMConversation>> GetConversationList(IEnumerable<string> ids) { public async Task<ReadOnlyCollection<LCIMConversation>> GetConversationList(IEnumerable<string> ids) {
if (ids == null || ids.Count() == 0) { if (ids == null || ids.Count() == 0) {
@ -423,7 +418,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 获取对话查询对象 /// Constructs a conversation query.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public LCIMConversationQuery GetQuery() { public LCIMConversationQuery GetQuery() {

View File

@ -4,14 +4,14 @@ using LeanCloud.Realtime.Internal.Connection;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
public class LCRealtime { public class LCRealtime {
/// <summary> /// <summary>
/// RTM 服务中,每个 app 对应一条连接 /// Every application uses a connection.
/// </summary> /// </summary>
private static readonly Dictionary<string, LCConnection> appToConnections = new Dictionary<string, LCConnection>(); private static readonly Dictionary<string, LCConnection> appToConnections = new Dictionary<string, LCConnection>();
/// <summary> /// <summary>
/// 获取对应的 Connection /// Gets the connection.
/// </summary> /// </summary>
/// <param name="appId"></param> /// <param name="appId">App ID of the application</param>
/// <returns></returns> /// <returns></returns>
internal static LCConnection GetConnection(string appId) { internal static LCConnection GetConnection(string appId) {
if (appToConnections.TryGetValue(appId, out LCConnection connection)) { if (appToConnections.TryGetValue(appId, out LCConnection connection)) {
@ -23,15 +23,15 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 移除 Connection /// Removes the connection.
/// </summary> /// </summary>
/// <param name="connection"></param> /// <param name="connection">The LCConnection to remove</param>
internal static void RemoveConnection(LCConnection connection) { internal static void RemoveConnection(LCConnection connection) {
appToConnections.Remove(connection.id); appToConnections.Remove(connection.id);
} }
/// <summary> /// <summary>
/// 主动断开所有 RTM 连接 /// Disconnects all.
/// </summary> /// </summary>
public static void Pause() { public static void Pause() {
foreach (LCConnection connection in appToConnections.Values) { foreach (LCConnection connection in appToConnections.Values) {
@ -40,7 +40,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 主动恢复所有 RTM 连接 /// Reconnects all.
/// </summary> /// </summary>
public static void Resume() { public static void Resume() {
foreach (LCConnection connection in appToConnections.Values) { foreach (LCConnection connection in appToConnections.Values) {

View File

@ -2,13 +2,7 @@
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 音频消息
/// </summary>
public class LCIMAudioMessage : LCIMFileMessage { public class LCIMAudioMessage : LCIMFileMessage {
/// <summary>
/// 时长
/// </summary>
public double Duration { public double Duration {
get; private set; get; private set;
} }

View File

@ -1,11 +1,5 @@
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 二进制消息
/// </summary>
public class LCIMBinaryMessage : LCIMMessage { public class LCIMBinaryMessage : LCIMMessage {
/// <summary>
/// 消息数据
/// </summary>
public byte[] Data { public byte[] Data {
get; internal set; get; internal set;
} }

View File

@ -4,33 +4,27 @@ using System.Collections.Generic;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 文件消息
/// </summary>
public class LCIMFileMessage : LCIMTextMessage { public class LCIMFileMessage : LCIMTextMessage {
/// <summary>
/// 文件
/// </summary>
public LCFile File { public LCFile File {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 文件大小 /// The size of the file in bytes.
/// </summary> /// </summary>
public int Size { public int Size {
get; private set; get; private set;
} }
/// <summary> /// <summary>
/// 文件扩展名 /// The format extension of the file.
/// </summary> /// </summary>
public string Format { public string Format {
get; private set; get; private set;
} }
/// <summary> /// <summary>
/// 文件链接 /// The URL of the file.
/// </summary> /// </summary>
public string Url { public string Url {
get { get {

View File

@ -2,20 +2,11 @@
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 图像消息
/// </summary>
public class LCIMImageMessage : LCIMFileMessage { public class LCIMImageMessage : LCIMFileMessage {
/// <summary>
/// 图像宽度
/// </summary>
public int Width { public int Width {
get; private set; get; private set;
} }
/// <summary>
/// 图像高度
/// </summary>
public int Height { public int Height {
get; private set; get; private set;
} }

View File

@ -3,13 +3,7 @@ using System.Collections.Generic;
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 位置消息
/// </summary>
public class LCIMLocationMessage : LCIMTextMessage { public class LCIMLocationMessage : LCIMTextMessage {
/// <summary>
/// 位置
/// </summary>
public LCGeoPoint Location { public LCGeoPoint Location {
get; set; get; set;
} }

View File

@ -3,39 +3,39 @@ using System.Collections.Generic;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 消息基类 /// The base class of message.
/// </summary> /// </summary>
public abstract class LCIMMessage { public abstract class LCIMMessage {
/// <summary> /// <summary>
/// 消息所在对话 Id /// The conversation ID this message belongs to.
/// </summary> /// </summary>
public string ConversationId { public string ConversationId {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息 Id /// The ID of this message.
/// </summary> /// </summary>
public string Id { public string Id {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 发送者 Id /// The ID of the client who sends this message.
/// </summary> /// </summary>
public string FromClientId { public string FromClientId {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 发送时间戳 /// The timestamp of this message.
/// </summary> /// </summary>
public long SentTimestamp { public long SentTimestamp {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 发送时间 /// The sending date of this message.
/// </summary> /// </summary>
public DateTime SentAt { public DateTime SentAt {
get { get {
@ -52,7 +52,7 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 送达时间 /// The delivered date of this message.
/// </summary> /// </summary>
public DateTime DeliveredAt { public DateTime DeliveredAt {
get { get {
@ -62,14 +62,14 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 已读时间戳 /// The timestamp when this message has been read by others.
/// </summary> /// </summary>
public long ReadTimestamp { public long ReadTimestamp {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 已读时间 /// When this message has been read by others.
/// </summary> /// </summary>
public DateTime ReadAt { public DateTime ReadAt {
get { get {
@ -79,14 +79,14 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 修改时间戳 /// The timestamp when this message is updated.
/// </summary> /// </summary>
public long PatchedTimestamp { public long PatchedTimestamp {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 修改时间 /// When this message is updated.
/// </summary> /// </summary>
public DateTime PatchedAt { public DateTime PatchedAt {
get { get {
@ -96,28 +96,28 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 提醒成员 Id 列表 /// The members in the conversation mentioned by this message.
/// </summary> /// </summary>
public List<string> MentionIdList { public List<string> MentionIdList {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否提醒所有人 /// Whether all members in the conversation are mentioned by this message.
/// </summary> /// </summary>
public bool MentionAll { public bool MentionAll {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否提醒当前用户 /// Whether the current user has been mentioned in this message.
/// </summary> /// </summary>
public bool Mentioned { public bool Mentioned {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 是否是暂态消息 /// Indicates whether this message is transient.
/// </summary> /// </summary>
public bool IsTransient { public bool IsTransient {
get; internal set; get; internal set;

View File

@ -2,7 +2,7 @@
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 消息优先级 /// The priority for sending messages in chatroom.
/// </summary> /// </summary>
public enum LCIMMessagePriority { public enum LCIMMessagePriority {
Hight = 1, Hight = 1,
@ -11,32 +11,33 @@ namespace LeanCloud.Realtime {
} }
/// <summary> /// <summary>
/// 发送消息选项 /// The options for sending message.
/// </summary> /// </summary>
public class LCIMMessageSendOptions { public class LCIMMessageSendOptions {
/// <summary> /// <summary>
/// 是否作为暂态消息发送 /// Whether this is a transient message.
/// </summary> /// </summary>
public bool Transient { public bool Transient {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否需要消息回执,仅在普通对话中有效 /// Whether receipts are needed, only for normal conversations.
/// </summary> /// </summary>
public bool Receipt { public bool Receipt {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否作为遗愿消息发送 /// Whether this is a will message,
/// which will be sent automatically when a user goes offline unexpectedly.
/// </summary> /// </summary>
public bool Will { public bool Will {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 消息优先级,仅在暂态对话中有效 /// The priority for sending messages in chatroom.
/// </summary> /// </summary>
public LCIMMessagePriority Priority { public LCIMMessagePriority Priority {
get; set; get; set;

View File

@ -1,7 +1,7 @@
 
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 撤回消息 /// The recall message, i.e. a message to recall a previous sent message.
/// </summary> /// </summary>
public class LCIMRecalledMessage : LCIMTypedMessage { public class LCIMRecalledMessage : LCIMTypedMessage {
public LCIMRecalledMessage() { public LCIMRecalledMessage() {

View File

@ -1,13 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 文本消息
/// </summary>
public class LCIMTextMessage : LCIMTypedMessage { public class LCIMTextMessage : LCIMTypedMessage {
/// <summary>
/// 文本
/// </summary>
public string Text { public string Text {
get; set; get; set;
} }

View File

@ -6,40 +6,19 @@ using LeanCloud.Common;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 已知类型消息 /// Known message types.
/// </summary> /// </summary>
public class LCIMTypedMessage : LCIMMessage { public class LCIMTypedMessage : LCIMMessage {
/// <summary>
/// 文本消息
/// </summary>
public const int TextMessageType = -1; public const int TextMessageType = -1;
/// <summary>
/// 图像消息
/// </summary>
public const int ImageMessageType = -2; public const int ImageMessageType = -2;
/// <summary>
/// 音频消息
/// </summary>
public const int AudioMessageType = -3; public const int AudioMessageType = -3;
/// <summary>
/// 视频消息
/// </summary>
public const int VideoMessageType = -4; public const int VideoMessageType = -4;
/// <summary>
/// 位置消息
/// </summary>
public const int LocationMessageType = -5; public const int LocationMessageType = -5;
/// <summary>
/// 文件消息
/// </summary>
public const int FileMessageType = -6; public const int FileMessageType = -6;
/// <summary>
/// 撤回消息
/// </summary>
public const int RecalledMessageType = -127; public const int RecalledMessageType = -127;
/// <summary> /// <summary>
/// 保留字段 /// Preserved fields.
/// </summary> /// </summary>
protected const string MessageTypeKey = "_lctype"; protected const string MessageTypeKey = "_lctype";
protected const string MessageAttributesKey = "_lcattrs"; protected const string MessageAttributesKey = "_lcattrs";
@ -64,19 +43,16 @@ namespace LeanCloud.Realtime {
private Dictionary<string, object> customProperties; private Dictionary<string, object> customProperties;
/// <summary> /// <summary>
/// 完整的消息数据 /// Complete data of message.
/// </summary> /// </summary>
protected Dictionary<string, object> data = new Dictionary<string, object>(); protected Dictionary<string, object> data = new Dictionary<string, object>();
/// <summary>
/// 消息类型
/// </summary>
public virtual int MessageType { public virtual int MessageType {
get; private set; get; private set;
} }
/// <summary> /// <summary>
/// 消息属性访问 /// Gets message attributes.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -146,7 +122,7 @@ namespace LeanCloud.Realtime {
}; };
/// <summary> /// <summary>
/// 注册自定义类型消息 /// Registers a custom message type.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="msgType"></param> /// <param name="msgType"></param>

View File

@ -2,27 +2,15 @@
using LeanCloud.Storage; using LeanCloud.Storage;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 视频消息
/// </summary>
public class LCIMVideoMessage : LCIMFileMessage { public class LCIMVideoMessage : LCIMFileMessage {
/// <summary>
/// 宽度
/// </summary>
public int Width { public int Width {
get; private set; get; private set;
} }
/// <summary>
/// 高度
/// </summary>
public int Height { public int Height {
get; private set; get; private set;
} }
/// <summary>
/// 时长
/// </summary>
public double Duration { public double Duration {
get; private set; get; private set;
} }

View File

@ -1,27 +1,15 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 操作失败
/// </summary>
public class LCIMOperationFailure { public class LCIMOperationFailure {
/// <summary>
/// 失败码
/// </summary>
public int Code { public int Code {
get; set; get; set;
} }
/// <summary>
/// 失败原因
/// </summary>
public string Reason { public string Reason {
get; set; get; set;
} }
/// <summary>
/// 失败数据
/// </summary>
public List<string> IdList { public List<string> IdList {
get; set; get; set;
} }

View File

@ -1,20 +1,11 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 查询分页结果
/// </summary>
public class LCIMPageResult { public class LCIMPageResult {
/// <summary>
/// 当前分页数据集
/// </summary>
public ReadOnlyCollection<string> Results { public ReadOnlyCollection<string> Results {
get; internal set; get; internal set;
} }
/// <summary>
/// 下次请求的数据
/// </summary>
public string Next { public string Next {
get; internal set; get; internal set;
} }

View File

@ -1,20 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 部分成功结果
/// </summary>
public class LCIMPartiallySuccessResult { public class LCIMPartiallySuccessResult {
/// <summary>
/// 成功数据集
/// </summary>
public List<string> SuccessfulClientIdList { public List<string> SuccessfulClientIdList {
get; internal set; get; internal set;
} }
/// <summary>
/// 失败原因
/// </summary>
public List<LCIMOperationFailure> FailureList { public List<LCIMOperationFailure> FailureList {
get; internal set; get; internal set;
} }

View File

@ -2,41 +2,13 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 签名工程接口
/// </summary>
public interface ILCIMSignatureFactory { public interface ILCIMSignatureFactory {
/// <summary>
/// 登录签名
/// </summary>
/// <param name="clientId"></param>
/// <returns></returns>
Task<LCIMSignature> CreateConnectSignature(string clientId); Task<LCIMSignature> CreateConnectSignature(string clientId);
/// <summary>
/// 创建开启对话签名
/// </summary>
/// <returns></returns>
Task<LCIMSignature> CreateStartConversationSignature(string clientId, IEnumerable<string> memberIds); Task<LCIMSignature> CreateStartConversationSignature(string clientId, IEnumerable<string> memberIds);
/// <summary>
/// 创建会话相关签名
/// </summary>
/// <param name="conversationId"></param>
/// <param name="clientId"></param>
/// <param name="memberIds"></param>
/// <param name="action"></param>
/// <returns></returns>
Task<LCIMSignature> CreateConversationSignature(string conversationId, string clientId, IEnumerable<string> memberIds, string action); Task<LCIMSignature> CreateConversationSignature(string conversationId, string clientId, IEnumerable<string> memberIds, string action);
/// <summary>
/// 创建黑名单相关签名
/// </summary>
/// <param name="conversationId"></param>
/// <param name="clientId"></param>
/// <param name="memberIds"></param>
/// <param name="action"></param>
/// <returns></returns>
Task<LCIMSignature> CreateBlacklistSignature(string conversationId, string clientId, IEnumerable<string> memberIds, string action); Task<LCIMSignature> CreateBlacklistSignature(string conversationId, string clientId, IEnumerable<string> memberIds, string action);
} }
} }

View File

@ -1,24 +1,15 @@
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary>
/// 签名数据
/// </summary>
public class LCIMSignature { public class LCIMSignature {
/// <summary>
/// 签名
/// </summary>
public string Signature { public string Signature {
get; set; get; set;
} }
/// <summary>
/// 时间戳
/// </summary>
public long Timestamp { public long Timestamp {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 随机字符串 /// A random string.
/// </summary> /// </summary>
public string Nonce { public string Nonce {
get; set; get; set;

View File

@ -1,36 +1,18 @@
namespace LeanCloud.Realtime { namespace LeanCloud.Realtime {
/// <summary> /// <summary>
/// 支持签名的动作 /// Actions supporting signatures.
/// </summary> /// </summary>
public static class LCIMSignatureAction { public static class LCIMSignatureAction {
/// <summary>
/// 邀请
/// </summary>
public const string Invite = "invite"; public const string Invite = "invite";
/// <summary>
/// 踢出
/// </summary>
public const string Kick = "kick"; public const string Kick = "kick";
/// <summary>
/// 用户拉黑对话
/// </summary>
public const string ClientBlockConversations = "client-block-conversations"; public const string ClientBlockConversations = "client-block-conversations";
/// <summary>
/// 用户解除拉黑对话
/// </summary>
public const string ClientUnblockConversations = "client-unblock-conversations"; public const string ClientUnblockConversations = "client-unblock-conversations";
/// <summary>
/// 对话拉黑用户
/// </summary>
public const string ConversationBlockClients = "conversation-block-clients"; public const string ConversationBlockClients = "conversation-block-clients";
/// <summary>
/// 对话解除拉黑用户
/// </summary>
public const string ConversationUnblockClients = "conversation-unblock-clients"; public const string ConversationUnblockClients = "conversation-unblock-clients";
} }
} }

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace LiveQueryApp { namespace LiveQueryApp {
/// <summary> /// <summary>
/// 单线程环境,用于控制台应用 await 返回 /// Mimics UI thread under .Net console.
/// </summary> /// </summary>
public class SingleThreadSynchronizationContext : SynchronizationContext { public class SingleThreadSynchronizationContext : SynchronizationContext {
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>(); private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace RealtimeApp { namespace RealtimeApp {
/// <summary> /// <summary>
/// 单线程环境,用于控制台应用 await 返回 /// Mimics UI thread under .Net console.
/// </summary> /// </summary>
public class SingleThreadSynchronizationContext : SynchronizationContext { public class SingleThreadSynchronizationContext : SynchronizationContext {
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>(); private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 访问控制类 /// LeanCloud Access Control Lists.
/// </summary> /// </summary>
public class LCACL { public class LCACL {
const string PublicKey = "*"; const string PublicKey = "*";

View File

@ -5,7 +5,7 @@ using LeanCloud.Storage.Internal.Http;
namespace LeanCloud { namespace LeanCloud {
/// <summary> /// <summary>
/// LeanCloud 全局接口 /// LeanCloud Application
/// </summary> /// </summary>
public class LCApplication { public class LCApplication {
// SDK 版本号,用于 User-Agent 统计 // SDK 版本号,用于 User-Agent 统计

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 验证码 /// An image CAPTCHA to prevent SMS abuse.
/// </summary> /// </summary>
public class LCCapture { public class LCCapture {
public string Url { public string Url {
@ -17,14 +17,14 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 验证码工具类 /// Requests a CAPTCHA image and sends the verification code.
/// </summary> /// </summary>
public static class LCCaptchaClient { public static class LCCaptchaClient {
/// <summary> /// <summary>
/// 请求验证码 /// Requests a CAPTCHA image from LeanCloud.
/// </summary> /// </summary>
/// <param name="width">验证码图片宽度</param> /// <param name="width">Width of the CAPTCHA image.</param>
/// <param name="height">验证码图片高度</param> /// <param name="height">Height of the CAPTCHA image.</param>
/// <returns></returns> /// <returns></returns>
public static async Task<LCCapture> RequestCaptcha(int width = 82, public static async Task<LCCapture> RequestCaptcha(int width = 82,
int height = 39) { int height = 39) {
@ -41,10 +41,10 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 验证 /// Sends the code to LeanCloud for verification.
/// </summary> /// </summary>
/// <param name="code"></param> /// <param name="code">entered by the user</param>
/// <param name="token"></param> /// <param name="token">for LeanCloud to recognize which CAPTCHA to verify</param>
/// <returns></returns> /// <returns></returns>
public static async Task VerifyCaptcha(string code, public static async Task VerifyCaptcha(string code,
string token) { string token) {

View File

@ -4,24 +4,24 @@ using LeanCloud.Storage.Internal.Codec;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 云引擎 /// LeanEngine
/// </summary> /// </summary>
public static class LCCloud { public static class LCCloud {
private const string PRODUCTION_KEY = "X-LC-Prod"; private const string PRODUCTION_KEY = "X-LC-Prod";
/// <summary> /// <summary>
/// 是否是生产环境,默认为 true /// Whether using production environment (default) or staging environment.
/// </summary> /// </summary>
public static bool IsProduction { public static bool IsProduction {
get; set; get; set;
} = true; } = true;
/// <summary> /// <summary>
/// 调用云函数 /// Invokes a cloud function.
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name">Cloud function name.</param>
/// <param name="parameters"></param> /// <param name="parameters">Parameters of cloud function.</param>
/// <returns>返回类型为 Dictionary<string, object></returns> /// <returns>Dictionary<string, object> or List<object>.</returns>
public static async Task<Dictionary<string, object>> Run(string name, public static async Task<Dictionary<string, object>> Run(string name,
Dictionary<string, object> parameters = null) { Dictionary<string, object> parameters = null) {
string path = $"functions/{name}"; string path = $"functions/{name}";
@ -36,11 +36,11 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 调用 RPC 云函数 /// Invokes a cloud function as a remote procedure call.
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name">Cloud function name.</param>
/// <param name="parameters"></param> /// <param name="parameters">Parameters of cloud function.</param>
/// <returns>返回类型为 LCObject 容器类型</returns> /// <returns>LCObject, List<LCObject>, or Map<string, LCObject>.</returns>
public static async Task<object> RPC(string name, object parameters = null) { public static async Task<object> RPC(string name, object parameters = null) {
string path = $"call/{name}"; string path = $"call/{name}";
Dictionary<string, object> headers = new Dictionary<string, object> { Dictionary<string, object> headers = new Dictionary<string, object> {

View File

@ -2,16 +2,10 @@
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
public class LCGeoPoint { public class LCGeoPoint {
/// <summary>
/// 纬度
/// </summary>
public double Latitude { public double Latitude {
get; get;
} }
/// <summary>
/// 经度
/// </summary>
public double Longitude { public double Longitude {
get; get;
} }
@ -27,11 +21,6 @@ namespace LeanCloud.Storage {
} }
} }
/// <summary>
/// 据某点的距离(单位:千米)
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public double KilometersTo(LCGeoPoint point) { public double KilometersTo(LCGeoPoint point) {
if (point == null) { if (point == null) {
throw new ArgumentNullException(nameof(point)); throw new ArgumentNullException(nameof(point));
@ -39,11 +28,6 @@ namespace LeanCloud.Storage {
return RadiansTo(point) * 6371.0; return RadiansTo(point) * 6371.0;
} }
/// <summary>
/// 据某点的距离(单位:英里)
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public double MilesTo(LCGeoPoint point) { public double MilesTo(LCGeoPoint point) {
if (point == null) { if (point == null) {
throw new ArgumentNullException(nameof(point)); throw new ArgumentNullException(nameof(point));
@ -51,11 +35,6 @@ namespace LeanCloud.Storage {
return RadiansTo(point) * 3958.8; return RadiansTo(point) * 3958.8;
} }
/// <summary>
/// 据某点的距离(单位:弧度)
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public double RadiansTo(LCGeoPoint point) { public double RadiansTo(LCGeoPoint point) {
if (point == null) { if (point == null) {
throw new ArgumentNullException(nameof(point)); throw new ArgumentNullException(nameof(point));

View File

@ -10,21 +10,21 @@ using LeanCloud.Storage.Internal.Codec;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 对象类 /// LeanCloud Object
/// </summary> /// </summary>
public class LCObject { public class LCObject {
/// <summary> /// <summary>
/// 最近一次与服务端同步的数据 /// Last synced data.
/// </summary> /// </summary>
LCObjectData data; LCObjectData data;
/// <summary> /// <summary>
/// 预算数据 /// Estimated data.
/// </summary> /// </summary>
internal Dictionary<string, object> estimatedData; internal Dictionary<string, object> estimatedData;
/// <summary> /// <summary>
/// 操作字典 /// Operations.
/// </summary> /// </summary>
internal Dictionary<string, ILCOperation> operationDict; internal Dictionary<string, ILCOperation> operationDict;
@ -134,7 +134,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 删除字段 /// Removes the key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
public void Unset(string key) { public void Unset(string key) {
@ -145,11 +145,7 @@ namespace LeanCloud.Storage {
ApplyOperation(key, deleteOp); ApplyOperation(key, deleteOp);
} }
/// <summary>
/// 增加关联
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void AddRelation(string key, LCObject value) { public void AddRelation(string key, LCObject value) {
if (string.IsNullOrEmpty(key)) { if (string.IsNullOrEmpty(key)) {
throw new ArgumentNullException(nameof(key)); throw new ArgumentNullException(nameof(key));
@ -161,11 +157,6 @@ namespace LeanCloud.Storage {
ApplyOperation(key, op); ApplyOperation(key, op);
} }
/// <summary>
/// 删除关联
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void RemoveRelation(string key, LCObject value) { public void RemoveRelation(string key, LCObject value) {
if (string.IsNullOrEmpty(key)) { if (string.IsNullOrEmpty(key)) {
throw new ArgumentNullException(nameof(key)); throw new ArgumentNullException(nameof(key));
@ -178,7 +169,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 增加数字属性值 /// Atomically increments the value of the given key with amount.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -194,7 +185,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 在数组属性中增加一个元素 /// Atomically adds value to the end of the array key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -210,7 +201,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 在数组属性中增加一组元素 /// Atomically adds values to the end of the array key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -226,7 +217,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 在数组属性中增加一个唯一元素 /// Atomically adds value to the array key, only if not already present.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -242,10 +233,10 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 在数组属性中增加一组唯一元素 /// Atomically adds values to the array key, only if not already present.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="values"></param>
public void AddAllUnique(string key, IEnumerable values) { public void AddAllUnique(string key, IEnumerable values) {
if (string.IsNullOrEmpty(key)) { if (string.IsNullOrEmpty(key)) {
throw new ArgumentNullException(nameof(key)); throw new ArgumentNullException(nameof(key));
@ -258,7 +249,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 移除某个元素 /// Atomically removes all value from the array key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -274,7 +265,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 移除一组元素 /// Atomically removes all values from the array key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -458,7 +449,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 序列化为 json 字符串 /// Serializes this LCObject to a JSON string.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string ToString() { public override string ToString() {
@ -469,7 +460,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 反序列化为 LCObject 对象 /// Deserializes a JSON string to a LCObject.
/// </summary> /// </summary>
/// <param name="json"></param> /// <param name="json"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -32,7 +32,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 查询类 /// A query to fetch LCObject.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class LCQuery<T> : LCQuery where T : LCObject { public class LCQuery<T> : LCQuery where T : LCObject {
@ -42,7 +42,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 等于 /// The value corresponding to key is equal to value, or the array corresponding to key contains value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -53,7 +53,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 不等于 /// The value corresponding to key is not equal to value, or the array corresponding to key does not contain value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -64,7 +64,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 包含 /// Values contains value corresponding to key, or values contains at least one element in the array corresponding to key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -75,7 +75,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 不包含 /// The value of key must not be contained in values.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -86,7 +86,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 包含全部 /// The array corresponding to key contains all elements in values.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="values"></param> /// <param name="values"></param>
@ -97,7 +97,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 存在 /// The attribute corresponding to key exists.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -107,7 +107,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 不存在 /// The attribute corresponding to key does not exist.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -117,7 +117,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 长度等于 /// The size of the array corresponding to key is equal to size.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="size"></param> /// <param name="size"></param>
@ -128,7 +128,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 大于 /// The value corresponding to key is greater than value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -139,7 +139,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 大于等于 /// The value corresponding to key is greater than or equal to value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -150,7 +150,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 小于 /// The value corresponding to key is less than value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -161,7 +161,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 小于等于 /// The value corresponding to key is less than or equal to value.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="value"></param> /// <param name="value"></param>
@ -171,42 +171,23 @@ namespace LeanCloud.Storage {
return this; return this;
} }
/// <summary>
/// 相邻
/// </summary>
/// <param name="key"></param>
/// <param name="point"></param>
/// <returns></returns>
public LCQuery<T> WhereNear(string key, LCGeoPoint point) { public LCQuery<T> WhereNear(string key, LCGeoPoint point) {
Condition.WhereNear(key, point); Condition.WhereNear(key, point);
return this; return this;
} }
/// <summary>
/// 在坐标区域内
/// </summary>
/// <param name="key"></param>
/// <param name="southwest"></param>
/// <param name="northeast"></param>
/// <returns></returns>
public LCQuery<T> WhereWithinGeoBox(string key, LCGeoPoint southwest, LCGeoPoint northeast) { public LCQuery<T> WhereWithinGeoBox(string key, LCGeoPoint southwest, LCGeoPoint northeast) {
Condition.WhereWithinGeoBox(key, southwest, northeast); Condition.WhereWithinGeoBox(key, southwest, northeast);
return this; return this;
} }
/// <summary>
/// 相关
/// </summary>
/// <param name="parent"></param>
/// <param name="key"></param>
/// <returns></returns>
public LCQuery<T> WhereRelatedTo(LCObject parent, string key) { public LCQuery<T> WhereRelatedTo(LCObject parent, string key) {
Condition.WhereRelatedTo(parent, key); Condition.WhereRelatedTo(parent, key);
return this; return this;
} }
/// <summary> /// <summary>
/// 前缀 /// The string corresponding to key has a prefix.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="prefix"></param> /// <param name="prefix"></param>
@ -217,7 +198,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 后缀 /// The string corresponding to key has a suffix.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="suffix"></param> /// <param name="suffix"></param>
@ -228,7 +209,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 字符串包含 /// The string corresponding to key has a subString.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="subString"></param> /// <param name="subString"></param>
@ -239,7 +220,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 正则匹配 /// Matches the regexp.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="regex"></param> /// <param name="regex"></param>
@ -251,7 +232,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 关系查询 /// The value of key must match query.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="query"></param> /// <param name="query"></param>
@ -262,7 +243,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 不满足子查询 /// The value of key must not match query.
/// </summary> /// </summary>
/// <typeparam name="K"></typeparam> /// <typeparam name="K"></typeparam>
/// <param name="key"></param> /// <param name="key"></param>
@ -273,28 +254,20 @@ namespace LeanCloud.Storage {
return this; return this;
} }
/// <summary>
/// 按 key 升序
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public LCQuery<T> OrderByAscending(string key) { public LCQuery<T> OrderByAscending(string key) {
Condition.OrderByAscending(key); Condition.OrderByAscending(key);
return this; return this;
} }
/// <summary>
/// 按 key 降序
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public LCQuery<T> OrderByDescending(string key) { public LCQuery<T> OrderByDescending(string key) {
Condition.OrderByDescending(key); Condition.OrderByDescending(key);
return this; return this;
} }
/// <summary> /// <summary>
/// 增加按 key 升序 /// Also sorts the results in ascending order by the given key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -304,7 +277,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 增加按 key 降序 /// Also sorts the results in descending order by the given key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -314,7 +287,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 拉取 key 的完整对象 /// Includes nested LCObject for the provided key.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -324,7 +297,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 包含 key /// Restricts the keys of the LCObject returned.
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <returns></returns> /// <returns></returns>
@ -334,7 +307,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 是否包含 ACL /// Includes the ALC or not.
/// </summary> /// </summary>
public bool IncludeACL { public bool IncludeACL {
get { get {
@ -345,7 +318,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 跳过 /// Sets the amount of results to skip before returning any results.
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
@ -355,7 +328,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 限制数量 /// Sets the limit of the number of results to return.
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -1,25 +1,14 @@
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary>
/// 关系类
/// </summary>
public class LCRelation<T> where T : LCObject { public class LCRelation<T> where T : LCObject {
/// <summary>
/// 字段名
/// </summary>
public string Key { public string Key {
get; set; get; set;
} }
/// <summary>
/// 父对象
/// </summary>
public LCObject Parent { public LCObject Parent {
get; set; get; set;
} }
/// <summary>
/// 关联类型名
/// </summary>
public string TargetClass { public string TargetClass {
get; set; get; set;
} }
@ -27,9 +16,6 @@
public LCRelation() { public LCRelation() {
} }
/// <summary>
/// 获取 Relation 的查询对象
/// </summary>
public LCQuery<T> Query { public LCQuery<T> Query {
get { get {
LCQuery<T> query = new LCQuery<T>(TargetClass); LCQuery<T> query = new LCQuery<T>(TargetClass);

View File

@ -1,13 +1,11 @@
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 角色 /// LeanCloud Role, a group of users for the purposes of granting permissions.
/// </summary> /// </summary>
public class LCRole : LCObject { public class LCRole : LCObject {
public const string CLASS_NAME = "_Role"; public const string CLASS_NAME = "_Role";
/// <summary>
/// 名字
/// </summary>
public string Name { public string Name {
get { get {
return this["name"] as string; return this["name"] as string;
@ -17,7 +15,7 @@
} }
/// <summary> /// <summary>
/// 关联角色 /// Child roles.
/// </summary> /// </summary>
public LCRelation<LCRole> Roles { public LCRelation<LCRole> Roles {
get { get {
@ -30,7 +28,7 @@
} }
/// <summary> /// <summary>
/// 关联用户 /// Child users.
/// </summary> /// </summary>
public LCRelation<LCUser> Users { public LCRelation<LCUser> Users {
get { get {
@ -54,7 +52,7 @@
} }
/// <summary> /// <summary>
/// 获取角色查询对象 /// Constructs a LCQuery for this role.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static LCQuery<LCRole> GetQuery() { public static LCQuery<LCRole> GetQuery() {

View File

@ -4,17 +4,17 @@ using System.Threading.Tasks;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 短信工具类 /// LeanCloud SMS Client
/// </summary> /// </summary>
public static class LCSMSClient { public static class LCSMSClient {
/// <summary> /// <summary>
/// 请求短信验证码 /// Requests an SMS code for operation verification.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="template"></param> /// <param name="template"></param>
/// <param name="signature"></param> /// <param name="signature"></param>
/// <param name="captchaToken"></param> /// <param name="captchaToken"></param>
/// <param name="variables"></param> /// <param name="variables">Template variables</param>
/// <returns></returns> /// <returns></returns>
public static async Task RequestSMSCode(string mobile, public static async Task RequestSMSCode(string mobile,
string template = null, string template = null,
@ -47,7 +47,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求语音验证码 /// Requests to send the verification code via phone call.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <returns></returns> /// <returns></returns>
@ -60,12 +60,6 @@ namespace LeanCloud.Storage {
await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: data); await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: data);
} }
/// <summary>
/// 验证手机号
/// </summary>
/// <param name="mobile"></param>
/// <param name="code"></param>
/// <returns></returns>
public static async Task VerifyMobilePhone(string mobile, string code) { public static async Task VerifyMobilePhone(string mobile, string code) {
string path = $"verifySmsCode/{code}"; string path = $"verifySmsCode/{code}";
Dictionary<string, object> data = new Dictionary<string, object> { Dictionary<string, object> data = new Dictionary<string, object> {

View File

@ -68,7 +68,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 是否是匿名登录 /// Checks whether this user is anonymous.
/// </summary> /// </summary>
public bool IsAnonymous => AuthData != null && public bool IsAnonymous => AuthData != null &&
AuthData.ContainsKey("anonymous"); AuthData.ContainsKey("anonymous");
@ -90,7 +90,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 注册 /// Signs up a new user.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<LCUser> SignUp() { public async Task<LCUser> SignUp() {
@ -111,9 +111,9 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求登录注册码 /// Requests sending a login sms code.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile">The mobile number of an existing user</param>
/// <returns></returns> /// <returns></returns>
public static async Task RequestLoginSMSCode(string mobile) { public static async Task RequestLoginSMSCode(string mobile) {
if (string.IsNullOrEmpty(mobile)) { if (string.IsNullOrEmpty(mobile)) {
@ -126,7 +126,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 使用手机号和验证码注册或登录 /// Signs up or signs in a user with their mobile number and verification code.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="code"></param> /// <param name="code"></param>
@ -149,7 +149,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 以账号和密码登陆 /// Signs in a user with their username and password.
/// </summary> /// </summary>
/// <param name="username"></param> /// <param name="username"></param>
/// <param name="password"></param> /// <param name="password"></param>
@ -169,7 +169,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 以邮箱和密码登陆 /// Signs in a user with their email and password.
/// </summary> /// </summary>
/// <param name="email"></param> /// <param name="email"></param>
/// <param name="password"></param> /// <param name="password"></param>
@ -189,7 +189,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 以手机号和密码登陆 /// Signs in a user with their mobile number and password.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="password"></param> /// <param name="password"></param>
@ -209,7 +209,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 以手机号和验证码登录 /// Signs in a user with their mobile number and verification code.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="code"></param> /// <param name="code"></param>
@ -229,7 +229,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 使用第三方数据登录 /// Signs up or signs in a user with third party authData.
/// </summary> /// </summary>
/// <param name="authData"></param> /// <param name="authData"></param>
/// <param name="platform"></param> /// <param name="platform"></param>
@ -250,7 +250,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 使用第三方数据和 Union Id 登录 /// Signs up or signs in a user with third party authData and unionId.
/// </summary> /// </summary>
/// <param name="authData"></param> /// <param name="authData"></param>
/// <param name="platform"></param> /// <param name="platform"></param>
@ -276,7 +276,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 绑定第三方登录 /// Associates this user with a third party authData.
/// </summary> /// </summary>
/// <param name="authData"></param> /// <param name="authData"></param>
/// <param name="platform"></param> /// <param name="platform"></param>
@ -292,7 +292,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 使用 Union Id 绑定第三方登录 /// Associates this user with a third party authData and unionId.
/// </summary> /// </summary>
/// <param name="authData"></param> /// <param name="authData"></param>
/// <param name="platform"></param> /// <param name="platform"></param>
@ -318,7 +318,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 解绑第三方登录 /// Unlinks a user from a third party platform.
/// </summary> /// </summary>
/// <param name="platform"></param> /// <param name="platform"></param>
/// <returns></returns> /// <returns></returns>
@ -330,7 +330,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 匿名登录 /// Creates an anonymous user.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static Task<LCUser> LoginAnonymously() { public static Task<LCUser> LoginAnonymously() {
@ -341,7 +341,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求验证邮箱 /// Requests a verification email to be sent to a user's email address.
/// </summary> /// </summary>
/// <param name="email"></param> /// <param name="email"></param>
/// <returns></returns> /// <returns></returns>
@ -356,7 +356,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求手机验证码 /// Requests a verification SMS to be sent to a user's mobile number.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <returns></returns> /// <returns></returns>
@ -371,7 +371,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 验证手机号 /// Requests to verify a user's mobile number with sms code they received.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="code"></param> /// <param name="code"></param>
@ -391,7 +391,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 设置当前用户 /// Signs in a user with a sessionToken.
/// </summary> /// </summary>
/// <param name="sessionToken"></param> /// <param name="sessionToken"></param>
/// <returns></returns> /// <returns></returns>
@ -410,7 +410,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求使用邮箱重置密码 /// Requests a password reset email to be sent to a user's email address.
/// </summary> /// </summary>
/// <param name="email"></param> /// <param name="email"></param>
/// <returns></returns> /// <returns></returns>
@ -426,7 +426,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求验证码重置密码 /// Requests a reset password sms code to be sent to a user's mobile number.
/// </summary> /// </summary>
/// <param name="email"></param> /// <param name="email"></param>
/// <returns></returns> /// <returns></returns>
@ -442,7 +442,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 使用验证码重置密码 /// Resets a user's password via mobile phone.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="code"></param> /// <param name="code"></param>
@ -467,7 +467,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 更新密码 /// Updates newPassword safely with oldPassword.
/// </summary> /// </summary>
/// <param name="oldPassword"></param> /// <param name="oldPassword"></param>
/// <param name="newPassword"></param> /// <param name="newPassword"></param>
@ -490,7 +490,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 注销登录 /// Logs out the currently logged in user session.
/// </summary> /// </summary>
public static Task Logout() { public static Task Logout() {
currentUser = null; currentUser = null;
@ -500,7 +500,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 是否是有效登录 /// Checks whether the current sessionToken is valid.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<bool> IsAuthenticated() { public async Task<bool> IsAuthenticated() {
@ -516,7 +516,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 得到 LCUser 类型的查询对象 /// Constructs a LCQuery for LCUser.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static LCQuery<LCUser> GetQuery() { public static LCQuery<LCUser> GetQuery() {
@ -557,7 +557,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 请求修改手机号验证码 /// Requests an SMS code for updating phone number.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="ttl"></param> /// <param name="ttl"></param>
@ -576,7 +576,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 验证修改手机号验证码 /// Verify code for updating phone number.
/// </summary> /// </summary>
/// <param name="mobile"></param> /// <param name="mobile"></param>
/// <param name="code"></param> /// <param name="code"></param>

View File

@ -1,24 +1,24 @@
/// <summary> /// <summary>
/// 第三方登录选项 /// LCUser UnionID login parameters.
/// </summary> /// </summary>
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
public class LCUserAuthDataLoginOption { public class LCUserAuthDataLoginOption {
/// <summary> /// <summary>
/// Union Id 平台 /// The platform of the UnionID.
/// </summary> /// </summary>
public string UnionIdPlatform { public string UnionIdPlatform {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否作为主账号 /// Whether the current authentication information will be used as the main account.
/// </summary> /// </summary>
public bool AsMainAccount { public bool AsMainAccount {
get; set; get; set;
} }
/// <summary> /// <summary>
/// 是否在不存在的情况下返回失败 /// Whether the login request will fail if no user matching this authData exists.
/// </summary> /// </summary>
public bool FailOnNotExist { public bool FailOnNotExist {
get; set; get; set;

View File

@ -7,121 +7,53 @@ using System.Collections.Generic;
using LeanCloud.Storage.Internal.Codec; using LeanCloud.Storage.Internal.Codec;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary>
/// 排行榜顺序
/// </summary>
public enum LCLeaderboardOrder { public enum LCLeaderboardOrder {
/// <summary>
/// 升序
/// </summary>
Ascending, Ascending,
/// <summary>
/// 降序
/// </summary>
Descending Descending
} }
/// <summary>
/// 排行榜更新策略
/// </summary>
public enum LCLeaderboardUpdateStrategy { public enum LCLeaderboardUpdateStrategy {
/// <summary>
/// 更好的
/// </summary>
Better, Better,
/// <summary>
/// 最近的
/// </summary>
Last, Last,
/// <summary>
/// 总和
/// </summary>
Sum Sum
} }
/// <summary>
/// 排行榜刷新频率
/// </summary>
public enum LCLeaderboardVersionChangeInterval { public enum LCLeaderboardVersionChangeInterval {
/// <summary>
/// 从不
/// </summary>
Never, Never,
/// <summary>
/// 每天
/// </summary>
Day, Day,
/// <summary>
/// 每周
/// </summary>
Week, Week,
/// <summary>
/// 每月
/// </summary>
Month Month
} }
/// <summary>
/// 排行榜
/// </summary>
public class LCLeaderboard { public class LCLeaderboard {
/// <summary>
/// 成绩名字
/// </summary>
public string StatisticName { public string StatisticName {
get; private set; get; private set;
} }
/// <summary>
/// 排名顺序
/// </summary>
public LCLeaderboardOrder Order { public LCLeaderboardOrder Order {
get; private set; get; private set;
} }
/// <summary>
/// 排名更新策略
/// </summary>
public LCLeaderboardUpdateStrategy UpdateStrategy { public LCLeaderboardUpdateStrategy UpdateStrategy {
get; private set; get; private set;
} }
/// <summary>
/// 版本更新频率
/// </summary>
public LCLeaderboardVersionChangeInterval VersionChangeInterval { public LCLeaderboardVersionChangeInterval VersionChangeInterval {
get; private set; get; private set;
} }
/// <summary>
/// 版本号
/// </summary>
public int Version { public int Version {
get; private set; get; private set;
} }
/// <summary>
/// 下次重置时间
/// </summary>
public DateTime NextResetAt { public DateTime NextResetAt {
get; private set; get; private set;
} }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreatedAt { public DateTime CreatedAt {
get; private set; get; private set;
} }
/// <summary>
/// 创建排行榜
/// </summary>
/// <param name="statisticName"></param>
/// <param name="order"></param>
/// <param name="updateStrategy"></param>
/// <param name="versionChangeInterval"></param>
/// <returns></returns>
public static async Task<LCLeaderboard> CreateLeaderboard(string statisticName, public static async Task<LCLeaderboard> CreateLeaderboard(string statisticName,
LCLeaderboardOrder order = LCLeaderboardOrder.Descending, LCLeaderboardOrder order = LCLeaderboardOrder.Descending,
LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better, LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better,
@ -144,7 +76,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 创建只包含名称的排行榜对象 /// Creates an empty leaderboard with a specified name.
/// </summary> /// </summary>
/// <param name="statisticName"></param> /// <param name="statisticName"></param>
/// <returns></returns> /// <returns></returns>
@ -157,23 +89,12 @@ namespace LeanCloud.Storage {
}; };
} }
/// <summary>
/// 获取排行榜
/// </summary>
/// <param name="statisticName"></param>
/// <returns></returns>
public static Task<LCLeaderboard> GetLeaderboard(string statisticName) { public static Task<LCLeaderboard> GetLeaderboard(string statisticName) {
LCLeaderboard leaderboard = CreateWithoutData(statisticName); LCLeaderboard leaderboard = CreateWithoutData(statisticName);
return leaderboard.Fetch(); return leaderboard.Fetch();
} }
/// <summary>
/// 更新用户成绩
/// </summary>
/// <param name="user"></param>
/// <param name="statistics"></param>
/// <param name="overwrite"></param>
/// <returns></returns>
public static async Task<ReadOnlyCollection<LCStatistic>> UpdateStatistics(LCUser user, public static async Task<ReadOnlyCollection<LCStatistic>> UpdateStatistics(LCUser user,
Dictionary<string, double> statistics, Dictionary<string, double> statistics,
bool overwrite = true) { bool overwrite = true) {
@ -205,12 +126,7 @@ namespace LeanCloud.Storage {
return null; return null;
} }
/// <summary>
/// 获得用户成绩
/// </summary>
/// <param name="user"></param>
/// <param name="statisticNames"></param>
/// <returns></returns>
public static async Task<ReadOnlyCollection<LCStatistic>> GetStatistics(LCUser user, public static async Task<ReadOnlyCollection<LCStatistic>> GetStatistics(LCUser user,
IEnumerable<string> statisticNames = null) { IEnumerable<string> statisticNames = null) {
if (user == null) { if (user == null) {
@ -234,12 +150,7 @@ namespace LeanCloud.Storage {
return null; return null;
} }
/// <summary>
/// 删除用户成绩
/// </summary>
/// <param name="user"></param>
/// <param name="statisticNames"></param>
/// <returns></returns>
public static async Task DeleteStatistics(LCUser user, public static async Task DeleteStatistics(LCUser user,
IEnumerable<string> statisticNames) { IEnumerable<string> statisticNames) {
if (user == null) { if (user == null) {
@ -254,7 +165,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 获取排行榜历史数据 /// Gets historical data of this leaderboard.
/// </summary> /// </summary>
/// <param name="skip"></param> /// <param name="skip"></param>
/// <param name="limit"></param> /// <param name="limit"></param>
@ -283,15 +194,7 @@ namespace LeanCloud.Storage {
return null; return null;
} }
/// <summary>
/// 获取排行榜结果
/// </summary>
/// <param name="version"></param>
/// <param name="skip"></param>
/// <param name="limit"></param>
/// <param name="selectUserKeys"></param>
/// <param name="includeStatistics"></param>
/// <returns></returns>
public Task<ReadOnlyCollection<LCRanking>> GetResults(int version = -1, public Task<ReadOnlyCollection<LCRanking>> GetResults(int version = -1,
int skip = 0, int skip = 0,
int limit = 10, int limit = 10,
@ -300,15 +203,7 @@ namespace LeanCloud.Storage {
return GetResults(null, version, skip, limit, selectUserKeys, includeStatistics); return GetResults(null, version, skip, limit, selectUserKeys, includeStatistics);
} }
/// <summary>
/// 获取用户及附近的排名
/// </summary>
/// <param name="version"></param>
/// <param name="skip"></param>
/// <param name="limit"></param>
/// <param name="selectUserKeys"></param>
/// <param name="includeStatistics"></param>
/// <returns></returns>
public async Task<ReadOnlyCollection<LCRanking>> GetResultsAroundUser(int version = -1, public async Task<ReadOnlyCollection<LCRanking>> GetResultsAroundUser(int version = -1,
int skip = 0, int skip = 0,
int limit = 10, int limit = 10,
@ -353,11 +248,7 @@ namespace LeanCloud.Storage {
return null; return null;
} }
/// <summary>
/// 设置更新策略
/// </summary>
/// <param name="updateStrategy"></param>
/// <returns></returns>
public async Task<LCLeaderboard> UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) { public async Task<LCLeaderboard> UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) {
Dictionary<string, object> data = new Dictionary<string, object> { Dictionary<string, object> data = new Dictionary<string, object> {
{ "updateStrategy", updateStrategy.ToString().ToLower() } { "updateStrategy", updateStrategy.ToString().ToLower() }
@ -372,11 +263,7 @@ namespace LeanCloud.Storage {
return this; return this;
} }
/// <summary>
/// 设置版本更新频率
/// </summary>
/// <param name="versionChangeInterval"></param>
/// <returns></returns>
public async Task<LCLeaderboard> UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) { public async Task<LCLeaderboard> UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) {
Dictionary<string, object> data = new Dictionary<string, object> { Dictionary<string, object> data = new Dictionary<string, object> {
{ "versionChangeInterval", versionChangeInterval.ToString().ToLower() } { "versionChangeInterval", versionChangeInterval.ToString().ToLower() }
@ -392,7 +279,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 拉取排行榜数据 /// Fetches leaderboard data.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<LCLeaderboard> Fetch() { public async Task<LCLeaderboard> Fetch() {
@ -403,7 +290,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 重置排行榜 /// Resets this leaderboard.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<LCLeaderboard> Reset() { public async Task<LCLeaderboard> Reset() {
@ -414,7 +301,7 @@ namespace LeanCloud.Storage {
} }
/// <summary> /// <summary>
/// 销毁排行榜 /// Destroys this leaderboard.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task Destroy() { public async Task Destroy() {

View File

@ -4,46 +4,37 @@ using LeanCloud.Storage.Internal.Codec;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary> /// <summary>
/// 归档的排行榜 /// Archived leaderboard.
/// </summary> /// </summary>
public class LCLeaderboardArchive { public class LCLeaderboardArchive {
/// <summary>
/// 名称
/// </summary>
public string StatisticName { public string StatisticName {
get; internal set; get; internal set;
} }
/// <summary>
/// 版本号
/// </summary>
public int Version { public int Version {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 状态 /// Archive status. One of scheduled, inProgress, failed, completed.
/// </summary> /// </summary>
public string Status { public string Status {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 下载地址 /// Download URL of the archived leaderboard file.
/// </summary> /// </summary>
public string Url { public string Url {
get; internal set; get; internal set;
} }
/// <summary>
/// 激活时间
/// </summary>
public DateTime ActivatedAt { public DateTime ActivatedAt {
get; internal set; get; internal set;
} }
/// <summary> /// <summary>
/// 归档时间 /// Archive time.
/// </summary> /// </summary>
public DateTime DeactivatedAt { public DateTime DeactivatedAt {
get; internal set; get; internal set;

View File

@ -4,41 +4,23 @@ using System.Collections.ObjectModel;
using LeanCloud.Storage.Internal.Object; using LeanCloud.Storage.Internal.Object;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary>
/// 排名
/// </summary>
public class LCRanking { public class LCRanking {
/// <summary>
/// 名次
/// </summary>
public int Rank { public int Rank {
get; private set; get; private set;
} }
/// <summary>
/// 用户
/// </summary>
public LCUser User { public LCUser User {
get; private set; get; private set;
} }
/// <summary>
/// 成绩名称
/// </summary>
public string StatisticName { public string StatisticName {
get; private set; get; private set;
} }
/// <summary>
/// 分数
/// </summary>
public double Value { public double Value {
get; private set; get; private set;
} }
/// <summary>
/// 成绩
/// </summary>
public ReadOnlyCollection<LCStatistic> IncludedStatistics { public ReadOnlyCollection<LCStatistic> IncludedStatistics {
get; private set; get; private set;
} }

View File

@ -2,27 +2,15 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LeanCloud.Storage { namespace LeanCloud.Storage {
/// <summary>
/// 成绩
/// </summary>
public class LCStatistic { public class LCStatistic {
/// <summary>
/// 排行榜名字
/// </summary>
public string Name { public string Name {
get; private set; get; private set;
} }
/// <summary>
/// 成绩值
/// </summary>
public double Value { public double Value {
get; private set; get; private set;
} }
/// <summary>
/// 排行榜版本
/// </summary>
public int Version { public int Version {
get; internal set; get; internal set;
} }