/// <summary> /// 既存の接続に参加 /// </summary> /// <param name="id">RowKey</param> /// <param name="account">UserAccount</param> /// <returns>接続したChatAccount</returns> public async Task <ChatAccount> OpenBridge(Guid id, ChannelAccount account) { var ownerAccount = await FindAccount(id); if (ownerAccount == null) { return(null); } var self = await FindBridges(ownerAccount.UserId, account.Id); if (self != null) { return(self); } var newId = Guid.NewGuid(); var newAccount = new ChatAccount() { PartitionKey = ownerAccount.UserId, RowKey = newId.ToString(), OwnerId = ownerAccount.UserId, UserId = account.Id, Address = account.Address, Name = account.Name, ChannelId = account.ChannelId, Created = DateTime.UtcNow, Modified = DateTime.UtcNow, }; await m_Table.ExecuteAsync(TableOperation.Insert(newAccount)); return(newAccount); }
/// <summary> /// 接続の開始 /// </summary> /// <param name="account">UserAccount</param> /// <returns>接続したChatAccount</returns> public async Task <ChatAccount> CreateBridge(ChannelAccount account) { var find = await FindBridge(account.Id); if (find != null) { return(find); } var id = Guid.NewGuid(); var newAccount = new ChatAccount() { PartitionKey = account.Id, RowKey = id.ToString(), OwnerId = account.Id, UserId = account.Id, Address = account.Address, Name = account.Name, ChannelId = account.ChannelId, Created = DateTime.UtcNow, Modified = DateTime.UtcNow, }; await m_Table.ExecuteAsync(TableOperation.Insert(newAccount)); return(newAccount); }