Merge pull request #87 from weakish/en-api-doc
docs: api-doc zh -> en
commit
3aaa14cdcf
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace LeanCloud {
|
||||
/// <summary>
|
||||
/// LeanCloud 异常
|
||||
/// LeanCloud Exceptions
|
||||
/// </summary>
|
||||
public class LCException : Exception {
|
||||
/// <summary>
|
||||
/// 错误码
|
||||
/// Error code
|
||||
/// </summary>
|
||||
public int Code {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// Error message
|
||||
/// </summary>
|
||||
public new string Message {
|
||||
get; set;
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace LeanCloud.Common {
|
||||
/// <summary>
|
||||
/// 为 Json 解析提供异步接口
|
||||
/// Serialize and deserialize
|
||||
/// </summary>
|
||||
public static class LCJsonUtils {
|
||||
public static async Task<string> SerializeObjectAsync(object obj) {
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
namespace LeanCloud {
|
||||
/// <summary>
|
||||
/// 日志级别
|
||||
/// </summary>
|
||||
public enum LCLogLevel {
|
||||
/// <summary>
|
||||
/// 调试级别
|
||||
/// </summary>
|
||||
Debug,
|
||||
/// <summary>
|
||||
/// 警告级别
|
||||
/// </summary>
|
||||
Warn,
|
||||
/// <summary>
|
||||
/// 错误级别
|
||||
/// </summary>
|
||||
Error,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ using System.Text;
|
|||
|
||||
namespace LeanCloud {
|
||||
/// <summary>
|
||||
/// 日志类
|
||||
/// Logger
|
||||
/// </summary>
|
||||
public static class LCLogger {
|
||||
/// <summary>
|
||||
/// 日志回调接口,方便开发者调试
|
||||
/// Configures the logger.
|
||||
/// </summary>
|
||||
/// <value>The log delegate.</value>
|
||||
public static Action<LCLogLevel, string> LogDelegate {
|
||||
|
|
|
@ -10,45 +10,28 @@ using LeanCloud.Realtime.Internal.Connection;
|
|||
|
||||
namespace LeanCloud.LiveQuery.Internal {
|
||||
public class LCLiveQueryConnection {
|
||||
/// <summary>
|
||||
/// 发送超时
|
||||
/// </summary>
|
||||
private const int SEND_TIMEOUT = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 最大重连次数,超过后重置 Router 缓存后再次尝试重连
|
||||
/// After exceeding this limit, will reset the Router cache and try to reconnect again.
|
||||
/// </summary>
|
||||
private const int MAX_RECONNECT_TIMES = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 重连间隔
|
||||
/// </summary>
|
||||
private const int RECONNECT_INTERVAL = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 子协议
|
||||
/// </summary>
|
||||
private const string SUB_PROTOCOL = "lc.json.3";
|
||||
|
||||
/// <summary>
|
||||
/// 通知事件
|
||||
/// </summary>
|
||||
|
||||
internal Action<Dictionary<string, object>> OnNotification;
|
||||
|
||||
/// <summary>
|
||||
/// 断线事件
|
||||
/// </summary>
|
||||
internal Action OnDisconnect;
|
||||
|
||||
/// <summary>
|
||||
/// 重连成功事件
|
||||
/// </summary>
|
||||
internal Action OnReconnected;
|
||||
|
||||
internal string id;
|
||||
|
||||
/// <summary>
|
||||
/// 请求回调缓存
|
||||
/// Request callback cache
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, TaskCompletionSource<Dictionary<string, object>>> responses;
|
||||
|
||||
|
@ -90,7 +73,7 @@ namespace LeanCloud.LiveQuery.Internal {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置连接
|
||||
/// Resets connection
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task Reset() {
|
||||
|
@ -108,7 +91,7 @@ namespace LeanCloud.LiveQuery.Internal {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送请求,会在收到应答后返回
|
||||
/// Sends the request. It will return after receiving a response.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -127,7 +110,7 @@ namespace LeanCloud.LiveQuery.Internal {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送文本消息
|
||||
/// Sends text message.
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -142,7 +125,7 @@ namespace LeanCloud.LiveQuery.Internal {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭连接
|
||||
/// Closes the connection.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task Close() {
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LeanCloud.LiveQuery.Internal {
|
||||
/// <summary>
|
||||
/// LiveQuery 心跳控制器
|
||||
/// LiveQuery heartbeat controller
|
||||
/// </summary>
|
||||
internal class LCLiveQueryHeartBeat : LCHeartBeat {
|
||||
private readonly LCLiveQueryConnection connection;
|
||||
|
|
|
@ -13,27 +13,27 @@ namespace LeanCloud.LiveQuery {
|
|||
/// </summary>
|
||||
public class LCLiveQuery {
|
||||
/// <summary>
|
||||
/// 新对象创建事件
|
||||
/// A new LCObject which fulfills the LCQuery you subscribe is created.
|
||||
/// </summary>
|
||||
public Action<LCObject> OnCreate;
|
||||
/// <summary>
|
||||
/// 对象更新事件
|
||||
/// An existing LCObject which fulfills the LCQuery you subscribe is updated.
|
||||
/// </summary>
|
||||
public Action<LCObject, ReadOnlyCollection<string>> OnUpdate;
|
||||
/// <summary>
|
||||
/// 对象被删除
|
||||
/// An existing LCObject which fulfills the LCQuery you subscribe is deleted.
|
||||
/// </summary>
|
||||
public Action<string> OnDelete;
|
||||
/// <summary>
|
||||
/// 有新的满足条件的对象产生
|
||||
/// An existing LCObject which doesn't fulfill the LCQuery is updated and now it fulfills the LCQuery.
|
||||
/// </summary>
|
||||
public Action<LCObject, ReadOnlyCollection<string>> OnEnter;
|
||||
/// <summary>
|
||||
/// 不再满足条件
|
||||
/// An existing LCObject which fulfills the LCQuery is updated and now it doesn't fulfill the LCQuery.
|
||||
/// </summary>
|
||||
public Action<LCObject, ReadOnlyCollection<string>> OnLeave;
|
||||
/// <summary>
|
||||
/// 当一个用户登录成功
|
||||
/// A LCUser logged in successfully.
|
||||
/// </summary>
|
||||
public Action<LCUser> OnLogin;
|
||||
|
||||
|
@ -55,10 +55,7 @@ namespace LeanCloud.LiveQuery {
|
|||
|
||||
private static readonly string DeviceId = Guid.NewGuid().ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 订阅
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task Subscribe() {
|
||||
// TODO 判断当前连接情况
|
||||
if (connection == null) {
|
||||
|
@ -92,10 +89,6 @@ namespace LeanCloud.LiveQuery {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消订阅
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Unsubscribe() {
|
||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||
{ "id", DeviceId },
|
||||
|
|
|
@ -9,9 +9,6 @@ using LeanCloud.Realtime;
|
|||
|
||||
using static NUnit.Framework.TestContext;
|
||||
|
||||
/// <summary>
|
||||
/// Emoji 消息
|
||||
/// </summary>
|
||||
class EmojiMessage : LCIMTypedMessage {
|
||||
public const int EmojiMessageType = 1;
|
||||
|
||||
|
|
|
@ -5,25 +5,21 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 聊天室
|
||||
/// Chatroom
|
||||
/// </summary>
|
||||
public class LCIMChatRoom : LCIMConversation {
|
||||
public LCIMChatRoom(LCIMClient client) :
|
||||
base(client) {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线用户数量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetOnlineMembersCount() {
|
||||
return await GetMembersCount();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线用户
|
||||
/// Gets online members.
|
||||
/// </summary>
|
||||
/// <param name="limit"></param>
|
||||
/// <param name="limit">Query limit, defaults to 50.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<string>> GetOnlineMembers(int limit = 50) {
|
||||
return await Client.ConversationController.GetOnlineMembers(Id, limit);
|
||||
|
|
|
@ -7,32 +7,32 @@ using LeanCloud.Storage;
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 普通对话
|
||||
/// Conversation
|
||||
/// </summary>
|
||||
public class LCIMConversation {
|
||||
/// <summary>
|
||||
/// 对话 Id
|
||||
/// The ID of this conversation
|
||||
/// </summary>
|
||||
public string Id {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否唯一
|
||||
/// Indicates whether this conversation is normal and unique. The uniqueness is based on the members when creating.
|
||||
/// </summary>
|
||||
public bool Unique {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 唯一 Id
|
||||
/// If this conversation is unique, then it will have a unique ID.
|
||||
/// </summary>
|
||||
public string UniqueId {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对话名称
|
||||
/// The name of this conversation.
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get {
|
||||
|
@ -44,14 +44,14 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建者 Id
|
||||
/// The creator of this conversation.
|
||||
/// </summary>
|
||||
public string CreatorId {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成员 Id
|
||||
/// The members of this conversation.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<string> MemberIds {
|
||||
get {
|
||||
|
@ -60,7 +60,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 静音成员 Id
|
||||
/// Muted members of this conversation.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<string> MutedMemberIds {
|
||||
get {
|
||||
|
@ -69,42 +69,42 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 未读消息数量
|
||||
/// The count of the unread messages.
|
||||
/// </summary>
|
||||
public int Unread {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最新的一条消息
|
||||
/// The last message in this conversation.
|
||||
/// </summary>
|
||||
public LCIMMessage LastMessage {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// The created date of this conversation.
|
||||
/// </summary>
|
||||
public DateTime CreatedAt {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// The last updated date of this conversation.
|
||||
/// </summary>
|
||||
public DateTime UpdatedAt {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最新送达消息时间戳
|
||||
/// The last timestamp of the delivered message.
|
||||
/// </summary>
|
||||
public long LastDeliveredTimestamp {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最新送达消息时间
|
||||
/// The last date of the delivered message.
|
||||
/// </summary>
|
||||
public DateTime LastDeliveredAt {
|
||||
get {
|
||||
|
@ -114,14 +114,14 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最新已读消息时间戳
|
||||
/// The last timestamp of the message which has been read by other clients.
|
||||
/// </summary>
|
||||
public long LastReadTimestamp {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最新已读消息时间
|
||||
/// The last date of the message which has been read by other clients.
|
||||
/// </summary>
|
||||
public DateTime LastReadAt {
|
||||
get {
|
||||
|
@ -131,9 +131,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置/获取对话属性
|
||||
/// Custom attributes.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="key">Custom attribute name.</param>
|
||||
/// <returns></returns>
|
||||
public object this[string key] {
|
||||
get {
|
||||
|
@ -145,7 +145,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已静音
|
||||
/// Indicates whether offline notifications about this conversation has been muted.
|
||||
/// </summary>
|
||||
public bool IsMute {
|
||||
get; private set;
|
||||
|
@ -170,7 +170,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对话人数,或暂态对话的在线人数
|
||||
/// The count of members of this conversation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetMembersCount() {
|
||||
|
@ -178,7 +178,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将该会话标记为已读
|
||||
/// Mark the last message of this conversation as read.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -191,9 +191,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改对话属性
|
||||
/// Update attributes of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="attributes"></param>
|
||||
/// <param name="attributes">Attributes to update.</param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateInfo(Dictionary<string, object> attributes) {
|
||||
if (attributes == null || attributes.Count == 0) {
|
||||
|
@ -206,9 +206,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户到对话
|
||||
/// Adds members to this conversation.
|
||||
/// </summary>
|
||||
/// <param name="clientIds">用户 Id</param>
|
||||
/// <param name="clientIds">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<LCIMPartiallySuccessResult> AddMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -220,9 +220,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// Removes members from this conversation.
|
||||
/// </summary>
|
||||
/// <param name="removeIds">用户 Id</param>
|
||||
/// <param name="removeIds">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> RemoveMembers(IEnumerable<string> removeIds) {
|
||||
if (removeIds == null || removeIds.Count() == 0) {
|
||||
|
@ -234,7 +234,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加入对话
|
||||
/// Joins this conversation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Join() {
|
||||
|
@ -249,7 +249,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离开对话
|
||||
/// Leaves this conversation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Quit() {
|
||||
|
@ -261,9 +261,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息
|
||||
/// Sends a message in this conversation.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="message">The message to send.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMMessage> Send(LCIMMessage message,
|
||||
LCIMMessageSendOptions options = null) {
|
||||
|
@ -279,7 +279,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 静音
|
||||
/// Turns off the offline notifications of this conversation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Mute() {
|
||||
|
@ -288,7 +288,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消静音
|
||||
/// Turns on the offline notifications of this conversation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Unmute() {
|
||||
|
@ -297,9 +297,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁言
|
||||
/// Mutes members of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="clientIds"></param>
|
||||
/// <param name="clientIds">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> MuteMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -313,9 +313,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消禁言
|
||||
/// Unmutes members of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="clientIdList"></param>
|
||||
/// <param name="clientIdList">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> UnmuteMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -329,9 +329,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将用户加入黑名单
|
||||
/// Adds members to the blocklist of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="clientIds"></param>
|
||||
/// <param name="clientIds">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> BlockMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -341,9 +341,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将用户移除黑名单
|
||||
/// Removes members from the blocklist of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="clientIds"></param>
|
||||
/// <param name="clientIds">Member list.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPartiallySuccessResult> UnblockMembers(IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -353,9 +353,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 撤回消息
|
||||
/// Recalls a sent message.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="message">The message to recall.</param>
|
||||
/// <returns></returns>
|
||||
public async Task RecallMessage(LCIMMessage message) {
|
||||
if (message == null) {
|
||||
|
@ -365,10 +365,10 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改消息
|
||||
/// Updates a sent message.
|
||||
/// </summary>
|
||||
/// <param name="oldMessage"></param>
|
||||
/// <param name="newMessage"></param>
|
||||
/// <param name="oldMessage">The message to update.</param>
|
||||
/// <param name="newMessage">The updated message.</param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateMessage(LCIMMessage oldMessage, LCIMMessage newMessage) {
|
||||
if (oldMessage == null) {
|
||||
|
@ -381,10 +381,10 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新对话中成员的角色
|
||||
/// Updates the role of a member of this conversation.
|
||||
/// </summary>
|
||||
/// <param name="memberId"></param>
|
||||
/// <param name="role"></param>
|
||||
/// <param name="memberId">The member to update.</param>
|
||||
/// <param name="role">The new role of the member.</param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateMemberRole(string memberId, string role) {
|
||||
if (string.IsNullOrEmpty(memberId)) {
|
||||
|
@ -397,7 +397,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对话中成员的角色(只返回管理员)
|
||||
/// Gets all member roles.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo() {
|
||||
|
@ -405,9 +405,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对话中指定成员的角色
|
||||
/// Gets the role of a specific member.
|
||||
/// </summary>
|
||||
/// <param name="memberId"></param>
|
||||
/// <param name="memberId">The member to query.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMConversationMemberInfo> GetMemberInfo(string memberId) {
|
||||
if (string.IsNullOrEmpty(memberId)) {
|
||||
|
@ -423,10 +423,10 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询禁言用户
|
||||
/// Queries muted members.
|
||||
/// </summary>
|
||||
/// <param name="limit"></param>
|
||||
/// <param name="next"></param>
|
||||
/// <param name="limit">Limits the number of returned results.</param>
|
||||
/// <param name="next">Can be used for pagination with the limit parameter.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPageResult> QueryMutedMembers(int limit = 10,
|
||||
string next = null) {
|
||||
|
@ -434,10 +434,10 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询黑名单用户
|
||||
/// Queries blocked members.
|
||||
/// </summary>
|
||||
/// <param name="limit">限制</param>
|
||||
/// <param name="next">其实用户 Id</param>
|
||||
/// <param name="limit">Limits the number of returned results.</param>
|
||||
/// <param name="next">Can be used for pagination with the limit parameter.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMPageResult> QueryBlockedMembers(int limit = 10,
|
||||
string next = null) {
|
||||
|
@ -445,13 +445,13 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询聊天记录
|
||||
/// Retrieves messages.
|
||||
/// </summary>
|
||||
/// <param name="start">起点</param>
|
||||
/// <param name="end">终点</param>
|
||||
/// <param name="direction">查找方向</param>
|
||||
/// <param name="limit">限制</param>
|
||||
/// <param name="messageType">消息类型</param>
|
||||
/// <param name="start">Start message ID.</param>
|
||||
/// <param name="end">End message ID.</param>
|
||||
/// <param name="direction">Query direction (defaults to NewToOld).</param>
|
||||
/// <param name="limit">Limits the number of returned results. Its default value is 20.</param>
|
||||
/// <param name="messageType">The message type to query. The default value is 0 (text message).</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<LCIMMessage>> QueryMessages(LCIMMessageQueryEndpoint start = null,
|
||||
LCIMMessageQueryEndpoint end = null,
|
||||
|
@ -462,7 +462,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取会话已收/已读时间戳
|
||||
/// Fetches receipt timestamp.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task FetchReciptTimestamps() {
|
||||
|
|
|
@ -1,18 +1,9 @@
|
|||
namespace LeanCloud.Realtime {
|
||||
public class LCIMConversationMemberInfo {
|
||||
/// <summary>
|
||||
/// 群主
|
||||
/// </summary>
|
||||
public const string Owner = "Owner";
|
||||
|
||||
/// <summary>
|
||||
/// 管理员
|
||||
/// </summary>
|
||||
public const string Manager = "Manager";
|
||||
|
||||
/// <summary>
|
||||
/// 成员
|
||||
/// </summary>
|
||||
public const string Member = "Member";
|
||||
|
||||
public string ConversationId {
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等于
|
||||
/// The value corresponding to key is equal to value, or the array corresponding to key contains value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -29,7 +29,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不等于
|
||||
/// The value corresponding to key is not equal to value, or the array corresponding to key does not contain value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -41,7 +41,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含
|
||||
/// Values contains value corresponding to key, or values contains at least one element in the array corresponding to key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -53,7 +53,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不包含
|
||||
/// The value of key must not be contained in values.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -65,7 +65,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含全部
|
||||
/// The array corresponding to key contains all elements in values.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -77,7 +77,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存在
|
||||
/// The attribute corresponding to key exists.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -87,7 +87,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不存在
|
||||
/// The attribute corresponding to key does not exist.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -97,7 +97,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 长度等于
|
||||
/// The size of the array corresponding to key is equal to size.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="size"></param>
|
||||
|
@ -109,7 +109,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 大于
|
||||
/// The value corresponding to key is greater than value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -121,7 +121,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 大于等于
|
||||
/// The value corresponding to key is greater than or equal to value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -133,7 +133,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小于
|
||||
/// The value corresponding to key is less than value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -145,7 +145,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小于等于
|
||||
/// The value corresponding to key is less than or equal to value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -157,7 +157,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 前缀
|
||||
/// The string corresponding to key has a prefix.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="prefix"></param>
|
||||
|
@ -169,7 +169,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后缀
|
||||
/// The string corresponding to key has a suffix.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="suffix"></param>
|
||||
|
@ -180,7 +180,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串包含
|
||||
/// The string corresponding to key has a subString.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="subString"></param>
|
||||
|
@ -191,9 +191,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 key 升序
|
||||
/// The ascending order by the value corresponding to key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="key">Multi-field sorting is supported with comma.</param>
|
||||
/// <returns></returns>
|
||||
public LCIMConversationQuery OrderBy(string key) {
|
||||
Condition.OrderByAscending(key);
|
||||
|
@ -201,9 +201,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 key 降序
|
||||
/// The descending order by the value corresponding to key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="key">Multi-field sorting is supported with comma.</param>
|
||||
/// <returns></returns>
|
||||
public LCIMConversationQuery OrderByDescending(string key) {
|
||||
Condition.OrderByDescending(key);
|
||||
|
@ -211,7 +211,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拉取 key 的完整对象
|
||||
/// Includes nested LCObject for the provided key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -221,7 +221,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含 key
|
||||
/// Restricts the keys of the LCObject returned.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -231,7 +231,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 跳过
|
||||
/// Sets the amount of results to skip before returning any results.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -241,7 +241,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 限制数量
|
||||
/// Sets the limit of the number of results to return.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -255,7 +255,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找
|
||||
/// Retrieves a list of LCObjects matching this query.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<LCIMConversation>> Find() {
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 系统对话
|
||||
/// </summary>
|
||||
public class LCIMServiceConversation : LCIMConversation {
|
||||
public LCIMServiceConversation(LCIMClient client) : base(client) {
|
||||
}
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 临时对话
|
||||
/// </summary>
|
||||
public class LCIMTemporaryConversation : LCIMConversation {
|
||||
/// <summary>
|
||||
/// 过期时间
|
||||
/// </summary>
|
||||
public DateTime ExpiredAt {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否过期
|
||||
/// </summary>
|
||||
public bool IsExpired {
|
||||
get {
|
||||
return DateTime.Now > ExpiredAt;
|
||||
|
|
|
@ -10,7 +10,7 @@ using LeanCloud.Realtime.Internal.Protocol;
|
|||
|
||||
namespace LeanCloud.Realtime.Internal.Connection {
|
||||
/// <summary>
|
||||
/// 连接层,只与数据协议相关
|
||||
/// Connection layer
|
||||
/// </summary>
|
||||
public class LCConnection {
|
||||
// 请求/应答比对,即 I 相等
|
||||
|
@ -24,53 +24,29 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接状态
|
||||
/// </summary>
|
||||
enum State {
|
||||
/// <summary>
|
||||
/// 初始状态
|
||||
/// Initial
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 连接中
|
||||
/// </summary>
|
||||
Connecting,
|
||||
/// <summary>
|
||||
/// 连接成功
|
||||
/// Connected
|
||||
/// </summary>
|
||||
Open,
|
||||
/// <summary>
|
||||
/// 关闭的
|
||||
/// </summary>
|
||||
Closed,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送超时
|
||||
/// </summary>
|
||||
private const int SEND_TIMEOUT = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 最大重连次数,超过后重置 Router 缓存后再次尝试重连
|
||||
/// </summary>
|
||||
private const int MAX_RECONNECT_TIMES = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 重连间隔
|
||||
/// </summary>
|
||||
private const int RECONNECT_INTERVAL = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 子协议
|
||||
/// </summary>
|
||||
private const string SUB_PROTOCOL = "lc.protobuf2.3";
|
||||
|
||||
internal string id;
|
||||
|
||||
/// <summary>
|
||||
/// 请求回调缓存
|
||||
/// </summary>
|
||||
private readonly Dictionary<GenericCommand, TaskCompletionSource<GenericCommand>> requestToResponses;
|
||||
|
||||
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) {
|
||||
if (IsIdempotentCommand(request)) {
|
||||
GenericCommand sendingReq = requestToResponses.Keys.FirstOrDefault(item => {
|
||||
|
@ -166,11 +137,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
return await tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送命令
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task SendCommand(GenericCommand command) {
|
||||
LCLogger.Debug($"{id} => {FormatCommand(command)}");
|
||||
byte[] bytes = command.ToByteArray();
|
||||
|
@ -182,9 +148,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 断开连接
|
||||
/// </summary>
|
||||
private void Disconnect() {
|
||||
state = State.Closed;
|
||||
heartBeat.Stop();
|
||||
|
@ -194,10 +157,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息接收回调
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
private void OnMessage(byte[] bytes) {
|
||||
try {
|
||||
GenericCommand command = GenericCommand.Parser.ParseFrom(bytes);
|
||||
|
@ -241,18 +200,11 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接断开回调
|
||||
/// </summary>
|
||||
private void OnDisconnect() {
|
||||
Disconnect();
|
||||
_ = Reconnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置连接
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal void Reset() {
|
||||
Disconnect();
|
||||
// 重新创建连接组件
|
||||
|
@ -318,16 +270,10 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停连接
|
||||
/// </summary>
|
||||
internal void Pause() {
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复连接
|
||||
/// </summary>
|
||||
internal void Resume() {
|
||||
_ = Reconnect();
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@ using LeanCloud.Realtime.Internal.Protocol;
|
|||
|
||||
namespace LeanCloud.Realtime.Internal.Connection {
|
||||
/// <summary>
|
||||
/// 心跳控制器,由于 .Net Standard 2.0 不支持发送 ping frame,所以需要发送逻辑心跳
|
||||
/// 1. 每隔 180s 发送 ping 包
|
||||
/// 2. 接收到 pong 包刷新上次 pong 时间
|
||||
/// 3. 每隔 180s 检测 pong 包间隔,超过 360s 则认为断开
|
||||
/// Heartbeat controller is needed because .Net Standard 2.0 does not support sending ping frame.
|
||||
/// 1. Ping every 180 seconds.
|
||||
/// 2. Receiving a pong packet will refresh the pong interval.
|
||||
/// 3. Check pong interval every 180 seconds.
|
||||
/// If the interval is greater than 360 seconds, the connection is considered disconnected.
|
||||
/// </summary>
|
||||
public class LCHeartBeat {
|
||||
private const int PING_INTERVAL = 180 * 1000;
|
||||
|
@ -32,9 +33,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
this.connection = connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动心跳
|
||||
/// </summary>
|
||||
public void Start() {
|
||||
running = true;
|
||||
heartBeatCTS = new CancellationTokenSource();
|
||||
|
@ -92,9 +90,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
lastPongTime = DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止心跳监听
|
||||
/// </summary>
|
||||
public void Stop() {
|
||||
running = false;
|
||||
heartBeatCTS.Cancel();
|
||||
|
|
|
@ -16,17 +16,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
|
||||
#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(
|
||||
IEnumerable<string> members = null,
|
||||
string name = null,
|
||||
|
@ -94,11 +83,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return conversation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询成员数量
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<int> GetMembersCount(string convId) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
Cid = convId,
|
||||
|
@ -109,12 +94,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
Dictionary<string, object> attributes) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
|
@ -135,12 +115,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加成员
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="clientIds"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<LCIMPartiallySuccessResult> AddMembers(string convId,
|
||||
IEnumerable<string> clientIds) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
|
@ -165,12 +140,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return NewPartiallySuccessResult(allowedIds, errors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除成员
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="removeIds"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<LCIMPartiallySuccessResult> RemoveMembers(string convId,
|
||||
IEnumerable<string> removeIds) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
|
@ -195,11 +165,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return NewPartiallySuccessResult(allowedIds, errors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 静音
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task Mute(string convId) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
Cid = convId
|
||||
|
@ -209,11 +175,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
await Connection.SendRequest(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解除静音
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task Unmute(string convId) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
Cid = convId
|
||||
|
@ -223,12 +184,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
await Connection.SendRequest(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁言用户
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="clientIds"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<LCIMPartiallySuccessResult> MuteMembers(string convId,
|
||||
IEnumerable<string> clientIds) {
|
||||
if (clientIds == null || clientIds.Count() == 0) {
|
||||
|
@ -244,12 +199,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
IEnumerable<string> clientIds) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
|
@ -262,12 +212,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
IEnumerable<string> clientIds) {
|
||||
BlacklistCommand blacklist = new BlacklistCommand {
|
||||
|
@ -289,12 +234,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
IEnumerable<string> clientIds) {
|
||||
BlacklistCommand blacklist = new BlacklistCommand {
|
||||
|
@ -316,13 +256,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
string memberId,
|
||||
string role) {
|
||||
|
@ -339,11 +273,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
GenericCommand response = await Connection.SendRequest(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有成员角色
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<ReadOnlyCollection<LCIMConversationMemberInfo>> GetAllMemberInfo(string convId) {
|
||||
string path = "classes/_ConversationMemberInfo";
|
||||
string token = await Client.SessionController.GetToken();
|
||||
|
@ -367,13 +297,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
}).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,
|
||||
int limit = 10,
|
||||
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,
|
||||
int limit = 10,
|
||||
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) {
|
||||
GenericCommand command = new GenericCommand {
|
||||
Cmd = CommandType.Conv,
|
||||
|
@ -468,11 +381,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
}).ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取临时对话
|
||||
/// </summary>
|
||||
/// <param name="convIds"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<List<LCIMTemporaryConversation>> GetTemporaryConversations(IEnumerable<string> convIds) {
|
||||
if (convIds == null || convIds.Count() == 0) {
|
||||
return null;
|
||||
|
@ -493,11 +402,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return convList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拉取对话接收/已读情况
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task FetchReciptTimestamp(string convId) {
|
||||
ConvCommand convCommand = new ConvCommand {
|
||||
Cid = convId
|
||||
|
@ -511,12 +416,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
conversation.LastReadTimestamp = convCommand.MaxReadTimestamp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取在线成员
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="limit"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<ReadOnlyCollection<string>> GetOnlineMembers(string convId,
|
||||
int limit) {
|
||||
ConvCommand conv = new ConvCommand {
|
||||
|
@ -531,11 +431,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return members;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询是否订阅
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<bool> CheckSubscription(string convId) {
|
||||
ConvCommand conv = new ConvCommand();
|
||||
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) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
Client.OnInvited?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有用户加入会话
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMembersJoined(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> joinedIds = new ReadOnlyCollection<string>(convMessage.M);
|
||||
|
@ -688,11 +576,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnMembersJoined?.Invoke(conversation, joinedIds, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户离开会话
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnLeft(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
// 从内存中清除对话
|
||||
|
@ -700,11 +584,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnKicked?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员离开会话
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
private async Task OnMemberLeft(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> leftIdList = new ReadOnlyCollection<string>(convMessage.M);
|
||||
|
@ -712,31 +591,19 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnMembersLeft?.Invoke(conversation, leftIdList, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被禁言
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMuted(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
Client.OnMuted?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被解除禁言
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnUnmuted(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
Client.OnUnmuted?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被禁言
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMembersMuted(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> mutedMemberIds = new ReadOnlyCollection<string>(convMessage.M);
|
||||
|
@ -744,11 +611,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnMembersMuted?.Invoke(conversation, mutedMemberIds, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被解除禁言
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMembersUnmuted(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> unmutedMemberIds = new ReadOnlyCollection<string>(convMessage.M);
|
||||
|
@ -756,53 +619,31 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnMembersUnmuted?.Invoke(conversation, unmutedMemberIds, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被拉黑
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
private async Task OnBlocked(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
Client.OnBlocked?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被解除黑名单
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnUnblocked(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
Client.OnUnblocked?.Invoke(conversation, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有用户被拉黑
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMembersBlocked(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> blockedMemberIds = convMessage.M.ToList().AsReadOnly();
|
||||
Client.OnMembersBlocked?.Invoke(conversation, blockedMemberIds, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有用户被移除黑名单
|
||||
/// </summary>
|
||||
/// <param name="convMessage"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMembersUnblocked(ConvCommand convMessage) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||
ReadOnlyCollection<string> unblockedMemberIds = convMessage.M.ToList().AsReadOnly();
|
||||
Client.OnMembersUnblocked?.Invoke(conversation, unblockedMemberIds, convMessage.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对话属性被修改
|
||||
/// </summary>
|
||||
/// <param name="conv"></param>
|
||||
/// <returns></returns>
|
||||
private async Task OnPropertiesUpdated(ConvCommand conv) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid);
|
||||
Dictionary<string, object> updatedAttr = JsonConvert.DeserializeObject<Dictionary<string, object>>(conv.AttrModified.Data,
|
||||
|
@ -814,11 +655,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
conv.InitBy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户角色被修改
|
||||
/// </summary>
|
||||
/// <param name="conv"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMemberInfoChanged(ConvCommand conv) {
|
||||
LCIMConversation conversation = await Client.GetOrQueryConversation(conv.Cid);
|
||||
ConvMemberInfo memberInfo = conv.Info;
|
||||
|
|
|
@ -14,12 +14,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
|
||||
#region 内部接口
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<LCIMMessage> Send(string convId,
|
||||
LCIMMessage message,
|
||||
LCIMMessageSendOptions options) {
|
||||
|
@ -74,12 +69,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
return message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 撤回消息
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task RecallMessage(string convId,
|
||||
LCIMMessage message) {
|
||||
PatchCommand patch = new PatchCommand();
|
||||
|
@ -97,13 +87,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
LCIMMessage oldMessage,
|
||||
LCIMMessage newMessage) {
|
||||
|
@ -133,16 +116,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
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,
|
||||
LCIMMessageQueryEndpoint start = null,
|
||||
LCIMMessageQueryEndpoint end = null,
|
||||
|
@ -197,12 +170,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
}).ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确认收到消息
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="msgId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task Ack(string convId,
|
||||
string msgId) {
|
||||
AckCommand ack = new AckCommand {
|
||||
|
@ -214,12 +182,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
await Connection.SendCommand(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确认已读消息
|
||||
/// </summary>
|
||||
/// <param name="convId"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task Read(string convId,
|
||||
LCIMMessage msg) {
|
||||
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) {
|
||||
DirectCommand direct = notification.DirectMessage;
|
||||
// 反序列化消息
|
||||
|
@ -288,11 +246,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Client.OnMessage?.Invoke(conversation, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息被修改事件
|
||||
/// </summary>
|
||||
/// <param name="notification"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task OnMessagePatched(GenericCommand notification) {
|
||||
PatchCommand patchMessage = notification.PatchMessage;
|
||||
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) {
|
||||
RcpCommand rcp = notification.RcpMessage;
|
||||
string convId = rcp.Cid;
|
||||
|
|
|
@ -15,10 +15,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
|
||||
#region 内部接口
|
||||
|
||||
/// <summary>
|
||||
/// 打开会话
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task Open(bool force) {
|
||||
await Connection.Connect();
|
||||
|
||||
|
@ -32,10 +29,6 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
Connection.Register(Client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新打开会话,重连时调用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task Reopen() {
|
||||
SessionCommand session = await NewSessionCommand();
|
||||
session.R = true;
|
||||
|
@ -49,20 +42,14 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭会话
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task Close() {
|
||||
GenericCommand request = NewCommand(CommandType.Session, OpType.Close);
|
||||
await Connection.SendRequest(request);
|
||||
Connection.UnRegister(Client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取可用 token
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
internal async Task<string> GetToken() {
|
||||
if (IsExpired) {
|
||||
await Refresh();
|
||||
|
@ -134,11 +121,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 被关闭
|
||||
/// </summary>
|
||||
/// <param name="session"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private void OnClosed(SessionCommand session) {
|
||||
int code = session.Code;
|
||||
string reason = session.Reason;
|
||||
|
|
|
@ -5,13 +5,8 @@ using LeanCloud.Common;
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace LeanCloud.Realtime.Internal.Router {
|
||||
/// <summary>
|
||||
/// RTM Router
|
||||
/// </summary>
|
||||
|
||||
public class LCRTMRouter {
|
||||
/// <summary>
|
||||
/// 请求超时
|
||||
/// </summary>
|
||||
private const int REQUEST_TIMEOUT = 10000;
|
||||
|
||||
private LCRTMServer rtmServer;
|
||||
|
@ -19,10 +14,6 @@ namespace LeanCloud.Realtime.Internal.Router {
|
|||
public LCRTMRouter() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务器地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<LCRTMServer> GetServer() {
|
||||
if (rtmServer == null || !rtmServer.IsValid) {
|
||||
await Fetch();
|
||||
|
|
|
@ -4,40 +4,20 @@ using System.Net.WebSockets;
|
|||
using System.Text;
|
||||
|
||||
namespace LeanCloud.Realtime.Internal.WebSocket {
|
||||
/// <summary>
|
||||
/// WebSocket 客户端,负责底层连接和事件,只与通信协议相关
|
||||
/// </summary>
|
||||
public class LCWebSocketClient {
|
||||
// .net standard 2.0 好像在拼合 Frame 时有 bug,所以将这个值调整大一些
|
||||
private const int RECV_BUFFER_SIZE = 1024 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// 关闭超时
|
||||
/// </summary>
|
||||
private const int CLOSE_TIMEOUT = 5000;
|
||||
|
||||
/// <summary>
|
||||
/// 连接超时
|
||||
/// </summary>
|
||||
private const int CONNECT_TIMEOUT = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 消息事件
|
||||
/// </summary>
|
||||
public Action<byte[]> OnMessage;
|
||||
|
||||
/// <summary>
|
||||
/// 连接关闭
|
||||
/// </summary>
|
||||
public Action OnClose;
|
||||
|
||||
private ClientWebSocket ws;
|
||||
|
||||
/// <summary>
|
||||
/// 连接指定 ws 服务器
|
||||
/// </summary>
|
||||
/// <param name="server"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Connect(string server,
|
||||
string subProtocol = null) {
|
||||
LCLogger.Debug($"Connecting WebSocket: {server}");
|
||||
|
@ -57,10 +37,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主动关闭连接
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Close() {
|
||||
LCLogger.Debug("Closing WebSocket");
|
||||
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,
|
||||
WebSocketMessageType messageType = WebSocketMessageType.Binary) {
|
||||
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) {
|
||||
await Send(Encoding.UTF8.GetBytes(text), WebSocketMessageType.Text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task StartReceive() {
|
||||
byte[] buffer = new byte[RECV_BUFFER_SIZE];
|
||||
try {
|
||||
|
|
|
@ -8,39 +8,31 @@ using LeanCloud.Realtime.Internal.Protocol;
|
|||
using LeanCloud.Realtime.Internal.Controller;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 通信客户端
|
||||
/// </summary>
|
||||
|
||||
public class LCIMClient {
|
||||
/// <summary>
|
||||
/// 对话缓存
|
||||
/// Conversation cache
|
||||
/// </summary>
|
||||
internal Dictionary<string, LCIMConversation> ConversationDict;
|
||||
|
||||
/// <summary>
|
||||
/// 用户 Id
|
||||
/// Client Id
|
||||
/// </summary>
|
||||
public string Id {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户标识
|
||||
/// Client tag
|
||||
/// </summary>
|
||||
public string Tag {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备 Id
|
||||
/// </summary>
|
||||
public string DeviceId {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录 tokens
|
||||
/// </summary>
|
||||
internal string SessionToken {
|
||||
get; private set;
|
||||
}
|
||||
|
@ -50,21 +42,22 @@ namespace LeanCloud.Realtime {
|
|||
#region 连接状态事件
|
||||
|
||||
/// <summary>
|
||||
/// 客户端连接断开
|
||||
/// Occurs when the connection is lost.
|
||||
/// </summary>
|
||||
public Action OnPaused {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 客户端连接恢复正常
|
||||
/// Occurs when the connection is recovered.
|
||||
/// </summary>
|
||||
public Action OnResume {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public Action<int, string> OnClose {
|
||||
get; set;
|
||||
|
@ -75,92 +68,92 @@ namespace LeanCloud.Realtime {
|
|||
#region 对话事件
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被加入某个对话的黑名单
|
||||
/// Occurs when the current user is added into the blacklist of a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnBlocked {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当用户被解除黑名单
|
||||
/// Occurs when the current user is removed from the blacklist of a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnUnblocked {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户在某个对话中被禁言
|
||||
/// Occurs when the current user is muted in a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnMuted;
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户在某个对话中被解除禁言
|
||||
/// Occurs when the current user is unmuted in a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnUnmuted;
|
||||
|
||||
/// <summary>
|
||||
/// 该对话信息被更新
|
||||
/// Occurs when the properties of a conversation are updated.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyDictionary<string, object>, string> OnConversationInfoUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被添加至某个对话
|
||||
/// Occurs when the current user is invited to a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnInvited {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户被从某个对话中移除
|
||||
/// Occurs when the current user is kicked from a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnKicked {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有用户被添加至某个对话
|
||||
/// Occurs when a user joined a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersJoined {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被从某个对话中移除
|
||||
/// Occurs when a user left a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersLeft {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被加入某个对话的黑名单
|
||||
/// Occurs when a user is added to the blacklist of a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersBlocked {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被移出某个对话的黑名单
|
||||
/// Occurs when a user is removed from the blacklist of a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnblocked {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员在某个对话中被禁言
|
||||
/// Occurs when a user is muted in a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersMuted {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员被移出某个对话的黑名单
|
||||
/// Occurs when a user is unmuted in a conversation.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, ReadOnlyCollection<string>, string> OnMembersUnmuted {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 有成员的对话信息被更新
|
||||
/// Occurs when the properties of someone are updated.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string, string, string> OnMemberInfoUpdated;
|
||||
|
||||
|
@ -169,56 +162,56 @@ namespace LeanCloud.Realtime {
|
|||
#region 消息事件
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户收到消息
|
||||
/// Occurs when a new message is delivered to a conversation the current user is already in.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, LCIMMessage> OnMessage {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息被撤回
|
||||
/// Occurs when a message is recalled.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, LCIMRecalledMessage> OnMessageRecalled {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息被修改
|
||||
/// Occurs when a message is updated.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, LCIMMessage> OnMessageUpdated {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息已送达
|
||||
/// Occurs when a message is delivered.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnMessageDelivered {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息已读
|
||||
/// Occurs when a message is read.
|
||||
/// </summary>
|
||||
public Action<LCIMConversation, string> OnMessageRead {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 未读消息数目更新
|
||||
/// Occurs when the number of unreadMessagesCount is updatded.
|
||||
/// </summary>
|
||||
public Action<ReadOnlyCollection<LCIMConversation>> OnUnreadMessagesCountUpdated {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最近分发消息更新
|
||||
/// Occurs when the last delivered message is updated.
|
||||
/// </summary>
|
||||
public Action OnLastDeliveredAtUpdated {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最近已读消息更新
|
||||
/// Occurs when the last delivered message is updated.
|
||||
/// </summary>
|
||||
public Action OnLastReadAtUpdated {
|
||||
get; set;
|
||||
|
@ -289,9 +282,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// Signing in
|
||||
/// </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>
|
||||
public async Task Open(bool force = true) {
|
||||
try {
|
||||
|
@ -305,7 +298,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭
|
||||
/// Closes the session
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Close() {
|
||||
|
@ -314,12 +307,14 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建普通对话
|
||||
/// Creates a conversation
|
||||
/// </summary>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="unique"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="members">The list of clientIds of participants in this conversation (except the creator)</param>
|
||||
/// <param name="name">The name of this conversation</param>
|
||||
/// <param name="unique">Whether this conversation is unique;
|
||||
/// 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>
|
||||
public async Task<LCIMConversation> CreateConversation(
|
||||
IEnumerable<string> members,
|
||||
|
@ -333,10 +328,10 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建聊天室
|
||||
/// Creates a chatroom
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="name">The name of this chatroom</param>
|
||||
/// <param name="properties">Custom attributes of this chatroom</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMChatRoom> CreateChatRoom(
|
||||
string name,
|
||||
|
@ -348,11 +343,11 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建临时对话
|
||||
/// Creates a temporary conversation
|
||||
/// </summary>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="ttl"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="members">The list of clientIds of participants in this temporary conversation (except the creator)</param>
|
||||
/// <param name="ttl">TTL of this temporary conversation</param>
|
||||
/// <param name="properties">Custom attributes of this temporary conversation</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMTemporaryConversation> CreateTemporaryConversation(
|
||||
IEnumerable<string> members,
|
||||
|
@ -366,9 +361,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 id 获取对话
|
||||
/// Queries a conversation based on its id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="id">objectId</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LCIMConversation> GetConversation(string id) {
|
||||
if (string.IsNullOrEmpty(id)) {
|
||||
|
@ -392,9 +387,9 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某些特定的对话
|
||||
/// Queries conversations based on their ids.
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <param name="ids">objectId list</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ReadOnlyCollection<LCIMConversation>> GetConversationList(IEnumerable<string> ids) {
|
||||
if (ids == null || ids.Count() == 0) {
|
||||
|
@ -423,7 +418,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对话查询对象
|
||||
/// Constructs a conversation query.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public LCIMConversationQuery GetQuery() {
|
||||
|
|
|
@ -4,14 +4,14 @@ using LeanCloud.Realtime.Internal.Connection;
|
|||
namespace LeanCloud.Realtime {
|
||||
public class LCRealtime {
|
||||
/// <summary>
|
||||
/// RTM 服务中,每个 app 对应一条连接
|
||||
/// Every application uses a connection.
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, LCConnection> appToConnections = new Dictionary<string, LCConnection>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取对应的 Connection
|
||||
/// Gets the connection.
|
||||
/// </summary>
|
||||
/// <param name="appId"></param>
|
||||
/// <param name="appId">App ID of the application</param>
|
||||
/// <returns></returns>
|
||||
internal static LCConnection GetConnection(string appId) {
|
||||
if (appToConnections.TryGetValue(appId, out LCConnection connection)) {
|
||||
|
@ -23,15 +23,15 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除 Connection
|
||||
/// Removes the connection.
|
||||
/// </summary>
|
||||
/// <param name="connection"></param>
|
||||
/// <param name="connection">The LCConnection to remove</param>
|
||||
internal static void RemoveConnection(LCConnection connection) {
|
||||
appToConnections.Remove(connection.id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主动断开所有 RTM 连接
|
||||
/// Disconnects all.
|
||||
/// </summary>
|
||||
public static void Pause() {
|
||||
foreach (LCConnection connection in appToConnections.Values) {
|
||||
|
@ -40,7 +40,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主动恢复所有 RTM 连接
|
||||
/// Reconnects all.
|
||||
/// </summary>
|
||||
public static void Resume() {
|
||||
foreach (LCConnection connection in appToConnections.Values) {
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
using LeanCloud.Storage;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 音频消息
|
||||
/// </summary>
|
||||
public class LCIMAudioMessage : LCIMFileMessage {
|
||||
/// <summary>
|
||||
/// 时长
|
||||
/// </summary>
|
||||
public double Duration {
|
||||
get; private set;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 二进制消息
|
||||
/// </summary>
|
||||
public class LCIMBinaryMessage : LCIMMessage {
|
||||
/// <summary>
|
||||
/// 消息数据
|
||||
/// </summary>
|
||||
public byte[] Data {
|
||||
get; internal set;
|
||||
}
|
||||
|
|
|
@ -4,33 +4,27 @@ using System.Collections.Generic;
|
|||
using LeanCloud.Storage;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 文件消息
|
||||
/// </summary>
|
||||
public class LCIMFileMessage : LCIMTextMessage {
|
||||
/// <summary>
|
||||
/// 文件
|
||||
/// </summary>
|
||||
public LCFile File {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// The size of the file in bytes.
|
||||
/// </summary>
|
||||
public int Size {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件扩展名
|
||||
/// The format extension of the file.
|
||||
/// </summary>
|
||||
public string Format {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件链接
|
||||
/// The URL of the file.
|
||||
/// </summary>
|
||||
public string Url {
|
||||
get {
|
||||
|
|
|
@ -2,20 +2,11 @@
|
|||
using LeanCloud.Storage;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 图像消息
|
||||
/// </summary>
|
||||
public class LCIMImageMessage : LCIMFileMessage {
|
||||
/// <summary>
|
||||
/// 图像宽度
|
||||
/// </summary>
|
||||
public int Width {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图像高度
|
||||
/// </summary>
|
||||
public int Height {
|
||||
get; private set;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,7 @@ using System.Collections.Generic;
|
|||
using LeanCloud.Storage;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 位置消息
|
||||
/// </summary>
|
||||
public class LCIMLocationMessage : LCIMTextMessage {
|
||||
/// <summary>
|
||||
/// 位置
|
||||
/// </summary>
|
||||
public LCGeoPoint Location {
|
||||
get; set;
|
||||
}
|
||||
|
|
|
@ -3,39 +3,39 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 消息基类
|
||||
/// The base class of message.
|
||||
/// </summary>
|
||||
public abstract class LCIMMessage {
|
||||
/// <summary>
|
||||
/// 消息所在对话 Id
|
||||
/// The conversation ID this message belongs to.
|
||||
/// </summary>
|
||||
public string ConversationId {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息 Id
|
||||
/// The ID of this message.
|
||||
/// </summary>
|
||||
public string Id {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送者 Id
|
||||
/// The ID of the client who sends this message.
|
||||
/// </summary>
|
||||
public string FromClientId {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送时间戳
|
||||
/// The timestamp of this message.
|
||||
/// </summary>
|
||||
public long SentTimestamp {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送时间
|
||||
/// The sending date of this message.
|
||||
/// </summary>
|
||||
public DateTime SentAt {
|
||||
get {
|
||||
|
@ -52,7 +52,7 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 送达时间
|
||||
/// The delivered date of this message.
|
||||
/// </summary>
|
||||
public DateTime DeliveredAt {
|
||||
get {
|
||||
|
@ -62,14 +62,14 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 已读时间戳
|
||||
/// The timestamp when this message has been read by others.
|
||||
/// </summary>
|
||||
public long ReadTimestamp {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 已读时间
|
||||
/// When this message has been read by others.
|
||||
/// </summary>
|
||||
public DateTime ReadAt {
|
||||
get {
|
||||
|
@ -79,14 +79,14 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间戳
|
||||
/// The timestamp when this message is updated.
|
||||
/// </summary>
|
||||
public long PatchedTimestamp {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// When this message is updated.
|
||||
/// </summary>
|
||||
public DateTime PatchedAt {
|
||||
get {
|
||||
|
@ -96,28 +96,28 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提醒成员 Id 列表
|
||||
/// The members in the conversation mentioned by this message.
|
||||
/// </summary>
|
||||
public List<string> MentionIdList {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否提醒所有人
|
||||
/// Whether all members in the conversation are mentioned by this message.
|
||||
/// </summary>
|
||||
public bool MentionAll {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否提醒当前用户
|
||||
/// Whether the current user has been mentioned in this message.
|
||||
/// </summary>
|
||||
public bool Mentioned {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是暂态消息
|
||||
/// Indicates whether this message is transient.
|
||||
/// </summary>
|
||||
public bool IsTransient {
|
||||
get; internal set;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 消息优先级
|
||||
/// The priority for sending messages in chatroom.
|
||||
/// </summary>
|
||||
public enum LCIMMessagePriority {
|
||||
Hight = 1,
|
||||
|
@ -11,32 +11,33 @@ namespace LeanCloud.Realtime {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息选项
|
||||
/// The options for sending message.
|
||||
/// </summary>
|
||||
public class LCIMMessageSendOptions {
|
||||
/// <summary>
|
||||
/// 是否作为暂态消息发送
|
||||
/// Whether this is a transient message.
|
||||
/// </summary>
|
||||
public bool Transient {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要消息回执,仅在普通对话中有效
|
||||
/// Whether receipts are needed, only for normal conversations.
|
||||
/// </summary>
|
||||
public bool Receipt {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否作为遗愿消息发送
|
||||
/// Whether this is a will message,
|
||||
/// which will be sent automatically when a user goes offline unexpectedly.
|
||||
/// </summary>
|
||||
public bool Will {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息优先级,仅在暂态对话中有效
|
||||
/// The priority for sending messages in chatroom.
|
||||
/// </summary>
|
||||
public LCIMMessagePriority Priority {
|
||||
get; set;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 撤回消息
|
||||
/// The recall message, i.e. a message to recall a previous sent message.
|
||||
/// </summary>
|
||||
public class LCIMRecalledMessage : LCIMTypedMessage {
|
||||
public LCIMRecalledMessage() {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 文本消息
|
||||
/// </summary>
|
||||
public class LCIMTextMessage : LCIMTypedMessage {
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
public string Text {
|
||||
get; set;
|
||||
}
|
||||
|
|
|
@ -6,40 +6,19 @@ using LeanCloud.Common;
|
|||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 已知类型消息
|
||||
/// Known message types.
|
||||
/// </summary>
|
||||
public class LCIMTypedMessage : LCIMMessage {
|
||||
/// <summary>
|
||||
/// 文本消息
|
||||
/// </summary>
|
||||
public const int TextMessageType = -1;
|
||||
/// <summary>
|
||||
/// 图像消息
|
||||
/// </summary>
|
||||
public const int ImageMessageType = -2;
|
||||
/// <summary>
|
||||
/// 音频消息
|
||||
/// </summary>
|
||||
public const int AudioMessageType = -3;
|
||||
/// <summary>
|
||||
/// 视频消息
|
||||
/// </summary>
|
||||
public const int VideoMessageType = -4;
|
||||
/// <summary>
|
||||
/// 位置消息
|
||||
/// </summary>
|
||||
public const int LocationMessageType = -5;
|
||||
/// <summary>
|
||||
/// 文件消息
|
||||
/// </summary>
|
||||
public const int FileMessageType = -6;
|
||||
/// <summary>
|
||||
/// 撤回消息
|
||||
/// </summary>
|
||||
public const int RecalledMessageType = -127;
|
||||
|
||||
/// <summary>
|
||||
/// 保留字段
|
||||
/// Preserved fields.
|
||||
/// </summary>
|
||||
protected const string MessageTypeKey = "_lctype";
|
||||
protected const string MessageAttributesKey = "_lcattrs";
|
||||
|
@ -64,19 +43,16 @@ namespace LeanCloud.Realtime {
|
|||
private Dictionary<string, object> customProperties;
|
||||
|
||||
/// <summary>
|
||||
/// 完整的消息数据
|
||||
/// Complete data of message.
|
||||
/// </summary>
|
||||
protected Dictionary<string, object> data = new Dictionary<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// 消息类型
|
||||
/// </summary>
|
||||
public virtual int MessageType {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息属性访问
|
||||
/// Gets message attributes.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -146,7 +122,7 @@ namespace LeanCloud.Realtime {
|
|||
};
|
||||
|
||||
/// <summary>
|
||||
/// 注册自定义类型消息
|
||||
/// Registers a custom message type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="msgType"></param>
|
||||
|
|
|
@ -2,27 +2,15 @@
|
|||
using LeanCloud.Storage;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 视频消息
|
||||
/// </summary>
|
||||
public class LCIMVideoMessage : LCIMFileMessage {
|
||||
/// <summary>
|
||||
/// 宽度
|
||||
/// </summary>
|
||||
public int Width {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 高度
|
||||
/// </summary>
|
||||
public int Height {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时长
|
||||
/// </summary>
|
||||
public double Duration {
|
||||
get; private set;
|
||||
}
|
||||
|
|
|
@ -1,27 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 操作失败
|
||||
/// </summary>
|
||||
public class LCIMOperationFailure {
|
||||
/// <summary>
|
||||
/// 失败码
|
||||
/// </summary>
|
||||
public int Code {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 失败原因
|
||||
/// </summary>
|
||||
public string Reason {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 失败数据
|
||||
/// </summary>
|
||||
public List<string> IdList {
|
||||
get; set;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 查询分页结果
|
||||
/// </summary>
|
||||
public class LCIMPageResult {
|
||||
/// <summary>
|
||||
/// 当前分页数据集
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<string> Results {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下次请求的数据
|
||||
/// </summary>
|
||||
public string Next {
|
||||
get; internal set;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 部分成功结果
|
||||
/// </summary>
|
||||
public class LCIMPartiallySuccessResult {
|
||||
/// <summary>
|
||||
/// 成功数据集
|
||||
/// </summary>
|
||||
public List<string> SuccessfulClientIdList {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 失败原因
|
||||
/// </summary>
|
||||
public List<LCIMOperationFailure> FailureList {
|
||||
get; internal set;
|
||||
}
|
||||
|
|
|
@ -2,41 +2,13 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 签名工程接口
|
||||
/// </summary>
|
||||
public interface ILCIMSignatureFactory {
|
||||
/// <summary>
|
||||
/// 登录签名
|
||||
/// </summary>
|
||||
/// <param name="clientId"></param>
|
||||
/// <returns></returns>
|
||||
Task<LCIMSignature> CreateConnectSignature(string clientId);
|
||||
|
||||
/// <summary>
|
||||
/// 创建开启对话签名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 签名数据
|
||||
/// </summary>
|
||||
public class LCIMSignature {
|
||||
/// <summary>
|
||||
/// 签名
|
||||
/// </summary>
|
||||
public string Signature {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public long Timestamp {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机字符串
|
||||
/// A random string.
|
||||
/// </summary>
|
||||
public string Nonce {
|
||||
get; set;
|
||||
|
|
|
@ -1,36 +1,18 @@
|
|||
namespace LeanCloud.Realtime {
|
||||
/// <summary>
|
||||
/// 支持签名的动作
|
||||
/// Actions supporting signatures.
|
||||
/// </summary>
|
||||
public static class LCIMSignatureAction {
|
||||
/// <summary>
|
||||
/// 邀请
|
||||
/// </summary>
|
||||
public const string Invite = "invite";
|
||||
|
||||
/// <summary>
|
||||
/// 踢出
|
||||
/// </summary>
|
||||
public const string Kick = "kick";
|
||||
|
||||
/// <summary>
|
||||
/// 用户拉黑对话
|
||||
/// </summary>
|
||||
public const string ClientBlockConversations = "client-block-conversations";
|
||||
|
||||
/// <summary>
|
||||
/// 用户解除拉黑对话
|
||||
/// </summary>
|
||||
public const string ClientUnblockConversations = "client-unblock-conversations";
|
||||
|
||||
/// <summary>
|
||||
/// 对话拉黑用户
|
||||
/// </summary>
|
||||
public const string ConversationBlockClients = "conversation-block-clients";
|
||||
|
||||
/// <summary>
|
||||
/// 对话解除拉黑用户
|
||||
/// </summary>
|
||||
public const string ConversationUnblockClients = "conversation-unblock-clients";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LiveQueryApp {
|
||||
/// <summary>
|
||||
/// 单线程环境,用于控制台应用 await 返回
|
||||
/// Mimics UI thread under .Net console.
|
||||
/// </summary>
|
||||
public class SingleThreadSynchronizationContext : SynchronizationContext {
|
||||
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace RealtimeApp {
|
||||
/// <summary>
|
||||
/// 单线程环境,用于控制台应用 await 返回
|
||||
/// Mimics UI thread under .Net console.
|
||||
/// </summary>
|
||||
public class SingleThreadSynchronizationContext : SynchronizationContext {
|
||||
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 访问控制类
|
||||
/// LeanCloud Access Control Lists.
|
||||
/// </summary>
|
||||
public class LCACL {
|
||||
const string PublicKey = "*";
|
||||
|
|
|
@ -5,7 +5,7 @@ using LeanCloud.Storage.Internal.Http;
|
|||
|
||||
namespace LeanCloud {
|
||||
/// <summary>
|
||||
/// LeanCloud 全局接口
|
||||
/// LeanCloud Application
|
||||
/// </summary>
|
||||
public class LCApplication {
|
||||
// SDK 版本号,用于 User-Agent 统计
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// An image CAPTCHA to prevent SMS abuse.
|
||||
/// </summary>
|
||||
public class LCCapture {
|
||||
public string Url {
|
||||
|
@ -17,14 +17,14 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证码工具类
|
||||
/// Requests a CAPTCHA image and sends the verification code.
|
||||
/// </summary>
|
||||
public static class LCCaptchaClient {
|
||||
/// <summary>
|
||||
/// 请求验证码
|
||||
/// Requests a CAPTCHA image from LeanCloud.
|
||||
/// </summary>
|
||||
/// <param name="width">验证码图片宽度</param>
|
||||
/// <param name="height">验证码图片高度</param>
|
||||
/// <param name="width">Width of the CAPTCHA image.</param>
|
||||
/// <param name="height">Height of the CAPTCHA image.</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<LCCapture> RequestCaptcha(int width = 82,
|
||||
int height = 39) {
|
||||
|
@ -41,10 +41,10 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证
|
||||
/// Sends the code to LeanCloud for verification.
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="code">entered by the user</param>
|
||||
/// <param name="token">for LeanCloud to recognize which CAPTCHA to verify</param>
|
||||
/// <returns></returns>
|
||||
public static async Task VerifyCaptcha(string code,
|
||||
string token) {
|
||||
|
|
|
@ -4,24 +4,24 @@ using LeanCloud.Storage.Internal.Codec;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 云引擎
|
||||
/// LeanEngine
|
||||
/// </summary>
|
||||
public static class LCCloud {
|
||||
private const string PRODUCTION_KEY = "X-LC-Prod";
|
||||
|
||||
/// <summary>
|
||||
/// 是否是生产环境,默认为 true
|
||||
/// Whether using production environment (default) or staging environment.
|
||||
/// </summary>
|
||||
public static bool IsProduction {
|
||||
get; set;
|
||||
} = true;
|
||||
|
||||
/// <summary>
|
||||
/// 调用云函数
|
||||
/// Invokes a cloud function.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns>返回类型为 Dictionary<string, object></returns>
|
||||
/// <param name="name">Cloud function name.</param>
|
||||
/// <param name="parameters">Parameters of cloud function.</param>
|
||||
/// <returns>Dictionary<string, object> or List<object>.</returns>
|
||||
public static async Task<Dictionary<string, object>> Run(string name,
|
||||
Dictionary<string, object> parameters = null) {
|
||||
string path = $"functions/{name}";
|
||||
|
@ -36,11 +36,11 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调用 RPC 云函数
|
||||
/// Invokes a cloud function as a remote procedure call.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns>返回类型为 LCObject 容器类型</returns>
|
||||
/// <param name="name">Cloud function name.</param>
|
||||
/// <param name="parameters">Parameters of cloud function.</param>
|
||||
/// <returns>LCObject, List<LCObject>, or Map<string, LCObject>.</returns>
|
||||
public static async Task<object> RPC(string name, object parameters = null) {
|
||||
string path = $"call/{name}";
|
||||
Dictionary<string, object> headers = new Dictionary<string, object> {
|
||||
|
|
|
@ -2,16 +2,10 @@
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
public class LCGeoPoint {
|
||||
/// <summary>
|
||||
/// 纬度
|
||||
/// </summary>
|
||||
public double Latitude {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 经度
|
||||
/// </summary>
|
||||
public double Longitude {
|
||||
get;
|
||||
}
|
||||
|
@ -27,11 +21,6 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 据某点的距离(单位:千米)
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public double KilometersTo(LCGeoPoint point) {
|
||||
if (point == null) {
|
||||
throw new ArgumentNullException(nameof(point));
|
||||
|
@ -39,11 +28,6 @@ namespace LeanCloud.Storage {
|
|||
return RadiansTo(point) * 6371.0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 据某点的距离(单位:英里)
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public double MilesTo(LCGeoPoint point) {
|
||||
if (point == null) {
|
||||
throw new ArgumentNullException(nameof(point));
|
||||
|
@ -51,11 +35,6 @@ namespace LeanCloud.Storage {
|
|||
return RadiansTo(point) * 3958.8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 据某点的距离(单位:弧度)
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public double RadiansTo(LCGeoPoint point) {
|
||||
if (point == null) {
|
||||
throw new ArgumentNullException(nameof(point));
|
||||
|
|
|
@ -10,21 +10,21 @@ using LeanCloud.Storage.Internal.Codec;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 对象类
|
||||
/// LeanCloud Object
|
||||
/// </summary>
|
||||
public class LCObject {
|
||||
/// <summary>
|
||||
/// 最近一次与服务端同步的数据
|
||||
/// Last synced data.
|
||||
/// </summary>
|
||||
LCObjectData data;
|
||||
|
||||
/// <summary>
|
||||
/// 预算数据
|
||||
/// Estimated data.
|
||||
/// </summary>
|
||||
internal Dictionary<string, object> estimatedData;
|
||||
|
||||
/// <summary>
|
||||
/// 操作字典
|
||||
/// Operations.
|
||||
/// </summary>
|
||||
internal Dictionary<string, ILCOperation> operationDict;
|
||||
|
||||
|
@ -134,7 +134,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除字段
|
||||
/// Removes the key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void Unset(string key) {
|
||||
|
@ -145,11 +145,7 @@ namespace LeanCloud.Storage {
|
|||
ApplyOperation(key, deleteOp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加关联
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
||||
public void AddRelation(string key, LCObject value) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
@ -161,11 +157,6 @@ namespace LeanCloud.Storage {
|
|||
ApplyOperation(key, op);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除关联
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public void RemoveRelation(string key, LCObject value) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
@ -178,7 +169,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加数字属性值
|
||||
/// Atomically increments the value of the given key with amount.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -194,7 +185,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在数组属性中增加一个元素
|
||||
/// Atomically adds value to the end of the array key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -210,7 +201,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在数组属性中增加一组元素
|
||||
/// Atomically adds values to the end of the array key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -226,7 +217,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在数组属性中增加一个唯一元素
|
||||
/// Atomically adds value to the array key, only if not already present.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -242,10 +233,10 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在数组属性中增加一组唯一元素
|
||||
/// Atomically adds values to the array key, only if not already present.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="values"></param>
|
||||
public void AddAllUnique(string key, IEnumerable values) {
|
||||
if (string.IsNullOrEmpty(key)) {
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
|
@ -258,7 +249,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除某个元素
|
||||
/// Atomically removes all value from the array key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -274,7 +265,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除一组元素
|
||||
/// Atomically removes all values from the array key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -458,7 +449,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化为 json 字符串
|
||||
/// Serializes this LCObject to a JSON string.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString() {
|
||||
|
@ -469,7 +460,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化为 LCObject 对象
|
||||
/// Deserializes a JSON string to a LCObject.
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询类
|
||||
/// A query to fetch LCObject.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class LCQuery<T> : LCQuery where T : LCObject {
|
||||
|
@ -42,7 +42,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等于
|
||||
/// The value corresponding to key is equal to value, or the array corresponding to key contains value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -53,7 +53,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不等于
|
||||
/// The value corresponding to key is not equal to value, or the array corresponding to key does not contain value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -64,7 +64,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含
|
||||
/// Values contains value corresponding to key, or values contains at least one element in the array corresponding to key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -75,7 +75,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不包含
|
||||
/// The value of key must not be contained in values.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -86,7 +86,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含全部
|
||||
/// The array corresponding to key contains all elements in values.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
|
@ -97,7 +97,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存在
|
||||
/// The attribute corresponding to key exists.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -107,7 +107,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不存在
|
||||
/// The attribute corresponding to key does not exist.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -117,7 +117,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 长度等于
|
||||
/// The size of the array corresponding to key is equal to size.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="size"></param>
|
||||
|
@ -128,7 +128,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 大于
|
||||
/// The value corresponding to key is greater than value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -139,7 +139,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 大于等于
|
||||
/// The value corresponding to key is greater than or equal to value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -150,7 +150,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小于
|
||||
/// The value corresponding to key is less than value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -161,7 +161,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小于等于
|
||||
/// The value corresponding to key is less than or equal to value.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
|
@ -171,42 +171,23 @@ namespace LeanCloud.Storage {
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 相邻
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="point"></param>
|
||||
/// <returns></returns>
|
||||
public LCQuery<T> WhereNear(string key, LCGeoPoint point) {
|
||||
Condition.WhereNear(key, point);
|
||||
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) {
|
||||
Condition.WhereWithinGeoBox(key, southwest, northeast);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 相关
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public LCQuery<T> WhereRelatedTo(LCObject parent, string key) {
|
||||
Condition.WhereRelatedTo(parent, key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 前缀
|
||||
/// The string corresponding to key has a prefix.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="prefix"></param>
|
||||
|
@ -217,7 +198,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后缀
|
||||
/// The string corresponding to key has a suffix.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="suffix"></param>
|
||||
|
@ -228,7 +209,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串包含
|
||||
/// The string corresponding to key has a subString.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="subString"></param>
|
||||
|
@ -239,7 +220,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 正则匹配
|
||||
/// Matches the regexp.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="regex"></param>
|
||||
|
@ -251,7 +232,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关系查询
|
||||
/// The value of key must match query.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="query"></param>
|
||||
|
@ -262,7 +243,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不满足子查询
|
||||
/// The value of key must not match query.
|
||||
/// </summary>
|
||||
/// <typeparam name="K"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
|
@ -273,28 +254,20 @@ namespace LeanCloud.Storage {
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 key 升序
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public LCQuery<T> OrderByAscending(string key) {
|
||||
Condition.OrderByAscending(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 key 降序
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public LCQuery<T> OrderByDescending(string key) {
|
||||
Condition.OrderByDescending(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加按 key 升序
|
||||
/// Also sorts the results in ascending order by the given key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -304,7 +277,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加按 key 降序
|
||||
/// Also sorts the results in descending order by the given key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -314,7 +287,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拉取 key 的完整对象
|
||||
/// Includes nested LCObject for the provided key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -324,7 +297,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含 key
|
||||
/// Restricts the keys of the LCObject returned.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -334,7 +307,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含 ACL
|
||||
/// Includes the ALC or not.
|
||||
/// </summary>
|
||||
public bool IncludeACL {
|
||||
get {
|
||||
|
@ -345,7 +318,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 跳过
|
||||
/// Sets the amount of results to skip before returning any results.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -355,7 +328,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 限制数量
|
||||
/// Sets the limit of the number of results to return.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 关系类
|
||||
/// </summary>
|
||||
|
||||
public class LCRelation<T> where T : LCObject {
|
||||
/// <summary>
|
||||
/// 字段名
|
||||
/// </summary>
|
||||
public string Key {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 父对象
|
||||
/// </summary>
|
||||
public LCObject Parent {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联类型名
|
||||
/// </summary>
|
||||
public string TargetClass {
|
||||
get; set;
|
||||
}
|
||||
|
@ -27,9 +16,6 @@
|
|||
public LCRelation() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Relation 的查询对象
|
||||
/// </summary>
|
||||
public LCQuery<T> Query {
|
||||
get {
|
||||
LCQuery<T> query = new LCQuery<T>(TargetClass);
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 角色
|
||||
/// LeanCloud Role, a group of users for the purposes of granting permissions.
|
||||
/// </summary>
|
||||
public class LCRole : LCObject {
|
||||
public const string CLASS_NAME = "_Role";
|
||||
|
||||
/// <summary>
|
||||
/// 名字
|
||||
/// </summary>
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return this["name"] as string;
|
||||
|
@ -17,7 +15,7 @@
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联角色
|
||||
/// Child roles.
|
||||
/// </summary>
|
||||
public LCRelation<LCRole> Roles {
|
||||
get {
|
||||
|
@ -30,7 +28,7 @@
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联用户
|
||||
/// Child users.
|
||||
/// </summary>
|
||||
public LCRelation<LCUser> Users {
|
||||
get {
|
||||
|
@ -54,7 +52,7 @@
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色查询对象
|
||||
/// Constructs a LCQuery for this role.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static LCQuery<LCRole> GetQuery() {
|
||||
|
|
|
@ -4,17 +4,17 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 短信工具类
|
||||
/// LeanCloud SMS Client
|
||||
/// </summary>
|
||||
public static class LCSMSClient {
|
||||
/// <summary>
|
||||
/// 请求短信验证码
|
||||
/// Requests an SMS code for operation verification.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="signature"></param>
|
||||
/// <param name="captchaToken"></param>
|
||||
/// <param name="variables"></param>
|
||||
/// <param name="variables">Template variables</param>
|
||||
/// <returns></returns>
|
||||
public static async Task RequestSMSCode(string mobile,
|
||||
string template = null,
|
||||
|
@ -47,7 +47,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求语音验证码
|
||||
/// Requests to send the verification code via phone call.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -60,12 +60,6 @@ namespace LeanCloud.Storage {
|
|||
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) {
|
||||
string path = $"verifySmsCode/{code}";
|
||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是匿名登录
|
||||
/// Checks whether this user is anonymous.
|
||||
/// </summary>
|
||||
public bool IsAnonymous => AuthData != null &&
|
||||
AuthData.ContainsKey("anonymous");
|
||||
|
@ -90,7 +90,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册
|
||||
/// Signs up a new user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<LCUser> SignUp() {
|
||||
|
@ -111,9 +111,9 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求登录注册码
|
||||
/// Requests sending a login sms code.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="mobile">The mobile number of an existing user</param>
|
||||
/// <returns></returns>
|
||||
public static async Task RequestLoginSMSCode(string mobile) {
|
||||
if (string.IsNullOrEmpty(mobile)) {
|
||||
|
@ -126,7 +126,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用手机号和验证码注册或登录
|
||||
/// Signs up or signs in a user with their mobile number and verification code.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="code"></param>
|
||||
|
@ -149,7 +149,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以账号和密码登陆
|
||||
/// Signs in a user with their username and password.
|
||||
/// </summary>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="password"></param>
|
||||
|
@ -169,7 +169,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以邮箱和密码登陆
|
||||
/// Signs in a user with their email and password.
|
||||
/// </summary>
|
||||
/// <param name="email"></param>
|
||||
/// <param name="password"></param>
|
||||
|
@ -189,7 +189,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以手机号和密码登陆
|
||||
/// Signs in a user with their mobile number and password.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="password"></param>
|
||||
|
@ -209,7 +209,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以手机号和验证码登录
|
||||
/// Signs in a user with their mobile number and verification code.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="code"></param>
|
||||
|
@ -229,7 +229,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用第三方数据登录
|
||||
/// Signs up or signs in a user with third party authData.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
|
@ -250,7 +250,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用第三方数据和 Union Id 登录
|
||||
/// Signs up or signs in a user with third party authData and unionId.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
|
@ -276,7 +276,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定第三方登录
|
||||
/// Associates this user with a third party authData.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
|
@ -292,7 +292,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用 Union Id 绑定第三方登录
|
||||
/// Associates this user with a third party authData and unionId.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
|
@ -318,7 +318,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解绑第三方登录
|
||||
/// Unlinks a user from a third party platform.
|
||||
/// </summary>
|
||||
/// <param name="platform"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -330,7 +330,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 匿名登录
|
||||
/// Creates an anonymous user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Task<LCUser> LoginAnonymously() {
|
||||
|
@ -341,7 +341,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求验证邮箱
|
||||
/// Requests a verification email to be sent to a user's email address.
|
||||
/// </summary>
|
||||
/// <param name="email"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -356,7 +356,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求手机验证码
|
||||
/// Requests a verification SMS to be sent to a user's mobile number.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -371,7 +371,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证手机号
|
||||
/// Requests to verify a user's mobile number with sms code they received.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="code"></param>
|
||||
|
@ -391,7 +391,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前用户
|
||||
/// Signs in a user with a sessionToken.
|
||||
/// </summary>
|
||||
/// <param name="sessionToken"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -410,7 +410,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求使用邮箱重置密码
|
||||
/// Requests a password reset email to be sent to a user's email address.
|
||||
/// </summary>
|
||||
/// <param name="email"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -426,7 +426,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求验证码重置密码
|
||||
/// Requests a reset password sms code to be sent to a user's mobile number.
|
||||
/// </summary>
|
||||
/// <param name="email"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -442,7 +442,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用验证码重置密码
|
||||
/// Resets a user's password via mobile phone.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="code"></param>
|
||||
|
@ -467,7 +467,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新密码
|
||||
/// Updates newPassword safely with oldPassword.
|
||||
/// </summary>
|
||||
/// <param name="oldPassword"></param>
|
||||
/// <param name="newPassword"></param>
|
||||
|
@ -490,7 +490,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注销登录
|
||||
/// Logs out the currently logged in user session.
|
||||
/// </summary>
|
||||
public static Task Logout() {
|
||||
currentUser = null;
|
||||
|
@ -500,7 +500,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是有效登录
|
||||
/// Checks whether the current sessionToken is valid.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> IsAuthenticated() {
|
||||
|
@ -516,7 +516,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到 LCUser 类型的查询对象
|
||||
/// Constructs a LCQuery for LCUser.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static LCQuery<LCUser> GetQuery() {
|
||||
|
@ -557,7 +557,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求修改手机号验证码
|
||||
/// Requests an SMS code for updating phone number.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="ttl"></param>
|
||||
|
@ -576,7 +576,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证修改手机号验证码
|
||||
/// Verify code for updating phone number.
|
||||
/// </summary>
|
||||
/// <param name="mobile"></param>
|
||||
/// <param name="code"></param>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
/// <summary>
|
||||
/// 第三方登录选项
|
||||
/// LCUser UnionID login parameters.
|
||||
/// </summary>
|
||||
namespace LeanCloud.Storage {
|
||||
public class LCUserAuthDataLoginOption {
|
||||
/// <summary>
|
||||
/// Union Id 平台
|
||||
/// The platform of the UnionID.
|
||||
/// </summary>
|
||||
public string UnionIdPlatform {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否作为主账号
|
||||
/// Whether the current authentication information will be used as the main account.
|
||||
/// </summary>
|
||||
public bool AsMainAccount {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在不存在的情况下返回失败
|
||||
/// Whether the login request will fail if no user matching this authData exists.
|
||||
/// </summary>
|
||||
public bool FailOnNotExist {
|
||||
get; set;
|
||||
|
|
|
@ -7,121 +7,53 @@ using System.Collections.Generic;
|
|||
using LeanCloud.Storage.Internal.Codec;
|
||||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 排行榜顺序
|
||||
/// </summary>
|
||||
public enum LCLeaderboardOrder {
|
||||
/// <summary>
|
||||
/// 升序
|
||||
/// </summary>
|
||||
Ascending,
|
||||
/// <summary>
|
||||
/// 降序
|
||||
/// </summary>
|
||||
Descending
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排行榜更新策略
|
||||
/// </summary>
|
||||
public enum LCLeaderboardUpdateStrategy {
|
||||
/// <summary>
|
||||
/// 更好的
|
||||
/// </summary>
|
||||
Better,
|
||||
/// <summary>
|
||||
/// 最近的
|
||||
/// </summary>
|
||||
Last,
|
||||
/// <summary>
|
||||
/// 总和
|
||||
/// </summary>
|
||||
Sum
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排行榜刷新频率
|
||||
/// </summary>
|
||||
public enum LCLeaderboardVersionChangeInterval {
|
||||
/// <summary>
|
||||
/// 从不
|
||||
/// </summary>
|
||||
Never,
|
||||
/// <summary>
|
||||
/// 每天
|
||||
/// </summary>
|
||||
Day,
|
||||
/// <summary>
|
||||
/// 每周
|
||||
/// </summary>
|
||||
Week,
|
||||
/// <summary>
|
||||
/// 每月
|
||||
/// </summary>
|
||||
Month
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排行榜
|
||||
/// </summary>
|
||||
public class LCLeaderboard {
|
||||
/// <summary>
|
||||
/// 成绩名字
|
||||
/// </summary>
|
||||
public string StatisticName {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排名顺序
|
||||
/// </summary>
|
||||
public LCLeaderboardOrder Order {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排名更新策略
|
||||
/// </summary>
|
||||
public LCLeaderboardUpdateStrategy UpdateStrategy {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本更新频率
|
||||
/// </summary>
|
||||
public LCLeaderboardVersionChangeInterval VersionChangeInterval {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
public int Version {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下次重置时间
|
||||
/// </summary>
|
||||
public DateTime NextResetAt {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedAt {
|
||||
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,
|
||||
LCLeaderboardOrder order = LCLeaderboardOrder.Descending,
|
||||
LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better,
|
||||
|
@ -144,7 +76,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建只包含名称的排行榜对象
|
||||
/// Creates an empty leaderboard with a specified name.
|
||||
/// </summary>
|
||||
/// <param name="statisticName"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -157,23 +89,12 @@ namespace LeanCloud.Storage {
|
|||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取排行榜
|
||||
/// </summary>
|
||||
/// <param name="statisticName"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<LCLeaderboard> GetLeaderboard(string statisticName) {
|
||||
LCLeaderboard leaderboard = CreateWithoutData(statisticName);
|
||||
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,
|
||||
Dictionary<string, double> statistics,
|
||||
bool overwrite = true) {
|
||||
|
@ -205,12 +126,7 @@ namespace LeanCloud.Storage {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得用户成绩
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="statisticNames"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static async Task<ReadOnlyCollection<LCStatistic>> GetStatistics(LCUser user,
|
||||
IEnumerable<string> statisticNames = null) {
|
||||
if (user == null) {
|
||||
|
@ -234,12 +150,7 @@ namespace LeanCloud.Storage {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户成绩
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="statisticNames"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static async Task DeleteStatistics(LCUser user,
|
||||
IEnumerable<string> statisticNames) {
|
||||
if (user == null) {
|
||||
|
@ -254,7 +165,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取排行榜历史数据
|
||||
/// Gets historical data of this leaderboard.
|
||||
/// </summary>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="limit"></param>
|
||||
|
@ -283,15 +194,7 @@ namespace LeanCloud.Storage {
|
|||
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,
|
||||
int skip = 0,
|
||||
int limit = 10,
|
||||
|
@ -300,15 +203,7 @@ namespace LeanCloud.Storage {
|
|||
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,
|
||||
int skip = 0,
|
||||
int limit = 10,
|
||||
|
@ -353,11 +248,7 @@ namespace LeanCloud.Storage {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置更新策略
|
||||
/// </summary>
|
||||
/// <param name="updateStrategy"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task<LCLeaderboard> UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) {
|
||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||
{ "updateStrategy", updateStrategy.ToString().ToLower() }
|
||||
|
@ -372,11 +263,7 @@ namespace LeanCloud.Storage {
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置版本更新频率
|
||||
/// </summary>
|
||||
/// <param name="versionChangeInterval"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task<LCLeaderboard> UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) {
|
||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||
{ "versionChangeInterval", versionChangeInterval.ToString().ToLower() }
|
||||
|
@ -392,7 +279,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拉取排行榜数据
|
||||
/// Fetches leaderboard data.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<LCLeaderboard> Fetch() {
|
||||
|
@ -403,7 +290,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置排行榜
|
||||
/// Resets this leaderboard.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<LCLeaderboard> Reset() {
|
||||
|
@ -414,7 +301,7 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁排行榜
|
||||
/// Destroys this leaderboard.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Destroy() {
|
||||
|
|
|
@ -4,46 +4,37 @@ using LeanCloud.Storage.Internal.Codec;
|
|||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 归档的排行榜
|
||||
/// Archived leaderboard.
|
||||
/// </summary>
|
||||
public class LCLeaderboardArchive {
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string StatisticName {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
public int Version {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// Archive status. One of scheduled, inProgress, failed, completed.
|
||||
/// </summary>
|
||||
public string Status {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下载地址
|
||||
/// Download URL of the archived leaderboard file.
|
||||
/// </summary>
|
||||
public string Url {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活时间
|
||||
/// </summary>
|
||||
public DateTime ActivatedAt {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 归档时间
|
||||
/// Archive time.
|
||||
/// </summary>
|
||||
public DateTime DeactivatedAt {
|
||||
get; internal set;
|
||||
|
|
|
@ -4,41 +4,23 @@ using System.Collections.ObjectModel;
|
|||
using LeanCloud.Storage.Internal.Object;
|
||||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 排名
|
||||
/// </summary>
|
||||
public class LCRanking {
|
||||
/// <summary>
|
||||
/// 名次
|
||||
/// </summary>
|
||||
public int Rank {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户
|
||||
/// </summary>
|
||||
public LCUser User {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成绩名称
|
||||
/// </summary>
|
||||
public string StatisticName {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分数
|
||||
/// </summary>
|
||||
public double Value {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成绩
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<LCStatistic> IncludedStatistics {
|
||||
get; private set;
|
||||
}
|
||||
|
|
|
@ -2,27 +2,15 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
/// 成绩
|
||||
/// </summary>
|
||||
public class LCStatistic {
|
||||
/// <summary>
|
||||
/// 排行榜名字
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成绩值
|
||||
/// </summary>
|
||||
public double Value {
|
||||
get; private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排行榜版本
|
||||
/// </summary>
|
||||
public int Version {
|
||||
get; internal set;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue