초기커밋
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
public class CancelFriendRequestInterlockAction : FriendInterlockBase
|
||||
{
|
||||
public CancelFriendRequestInterlockAction(UserBase owner, string myGuid, string friendGuid) : base(owner, myGuid, friendGuid)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
FriendReqCacheRequest cache = new FriendReqCacheRequest(owner, getMyGuid(), getFriendGuid(), server_logic.getRedisConnector());
|
||||
var result = await cache.cancelFriendRequest();
|
||||
if (result.isFail()) return result;
|
||||
|
||||
//log
|
||||
var invokers = new List<ILogInvoker>();
|
||||
invokers.Add(new CancelFriendRequestBusinessLog(getMyGuid(), getFriendGuid()));
|
||||
var log_action = new LogActionEx(LogActionType.CancelFriendRequest);
|
||||
BusinessLogger.collectLogs(log_action, owner, invokers);
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
public class ChangeFriendFolderLocationInterlockAction : FriendInterlockBase
|
||||
{
|
||||
private string m_folder_name;
|
||||
|
||||
public ChangeFriendFolderLocationInterlockAction(UserBase owner, string myGuid, string friendGuid, string folderName) : base(owner, myGuid, friendGuid)
|
||||
{
|
||||
m_folder_name = folderName;
|
||||
}
|
||||
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var owner = getOwner();
|
||||
var friend_folder_action = owner.getEntityAction<FriendFolderAction>();
|
||||
|
||||
var result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "ChangeFriendFolderLocation", delegateChangeFriendFolderLocation);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
return result;
|
||||
|
||||
async Task<Result> delegateChangeFriendFolderLocation() => await changeFriendFolderLocation(owner);
|
||||
|
||||
}
|
||||
|
||||
private async Task<Result> changeFriendFolderLocation(Player owner)
|
||||
{
|
||||
var friend_folder_action = owner.getEntityAction<FriendFolderAction>();
|
||||
var result = friend_folder_action.changeFriendFolderLocation(getMyGuid(), getFriendGuid(), m_folder_name);
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
if (result.isFail()) return result;
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.None, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Nettention.Proud;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class ConfirmNewFriendInterlockAction : FriendInterlockBase
|
||||
{
|
||||
|
||||
public ConfirmNewFriendInterlockAction(UserBase owner, string myGuid, string friendGuid) : base(owner, myGuid, friendGuid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var owner = getOwner();
|
||||
var result = await owner.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "ConfirmNewFriend", delegateConfirmNewFriend);
|
||||
return result;
|
||||
|
||||
async Task<Result> delegateConfirmNewFriend() => await confirmNewFriend(owner, getMyGuid(), getFriendGuid());
|
||||
}
|
||||
|
||||
private async Task<Result> confirmNewFriend(Player owner, string myGuid, string guid)
|
||||
{
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var friend_agent_action = owner.getEntityAction<FriendAgentAction>();
|
||||
|
||||
if(myGuid.Equals(guid))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
var owner_friend = friend_agent_action.getFriend(guid);
|
||||
if(owner_friend == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
var friend_attribute = owner_friend.getEntityAttribute<FriendAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_attribute, () => $"friend_attribute is null !!!");
|
||||
friend_attribute.IsNew = 0;
|
||||
friend_attribute.modifiedEntityAttribute();
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.None, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
var result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class ConfirmNewReceivedFriendRequestInterlockAction : FriendInterlockBase
|
||||
{
|
||||
public ConfirmNewReceivedFriendRequestInterlockAction(UserBase owner, string myGuid, string friendGuid) : base(owner, myGuid, friendGuid)
|
||||
{
|
||||
|
||||
}
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var owner = getOwner();
|
||||
|
||||
FriendReqCacheRequest friend_req_cache = new FriendReqCacheRequest(owner, getMyGuid(), getFriendGuid(), server_logic.getRedisConnector());
|
||||
|
||||
var result = await friend_req_cache.confirmReceivedFriendRequest();
|
||||
if(result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"confirmReceivedFriendRequest error getMyGuid() : {getMyGuid()}, getFriendGuid() : {getFriendGuid()}");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DeleteFriendFolderInterlockAction : FriendInterlockBase
|
||||
{
|
||||
private FriendAttribute m_friend_attrib;
|
||||
public DeleteFriendFolderInterlockAction(UserBase owner, string myGuid, FriendAttribute friendAttib) : base(owner, myGuid, friendAttib.FriendGuid)
|
||||
{
|
||||
m_friend_attrib = friendAttib;
|
||||
}
|
||||
|
||||
public override Task<Result> doAction()
|
||||
{
|
||||
var result = new Result();
|
||||
m_friend_attrib.FolderName = ServerCommon.Constant.FRIEND_FOLDER_DEFUALT_NAME;
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class DeleteFriendInterlockAction : FriendInterlockBase
|
||||
{
|
||||
public DeleteFriendInterlockAction(UserBase owner, string myGuid, string deleteGuid) : base(owner, myGuid ,deleteGuid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var owner = getOwner();
|
||||
|
||||
var friend_agent_action = owner.getEntityAction<FriendAgentAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_agent_action, () => $"friend_agent_action is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var friend_attribute = friend_agent_action.getFriendAttribute(getFriendGuid());
|
||||
NullReferenceCheckHelper.throwIfNull(friend_attribute, () => $"friend_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
friend_attribute.deleteEntityAttribute();
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(owner, LogActionType.FriendDelete, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQDeleteFriend(getMyGuid(), getFriendGuid()));
|
||||
}
|
||||
var log_invoker = new DeleteFriendBusinessLog(getMyGuid(), getFriendGuid());
|
||||
batch.appendBusinessLog(log_invoker);
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
79
GameServer/Contents/Friend/LockAction/FriendInterlockBase.cs
Normal file
79
GameServer/Contents/Friend/LockAction/FriendInterlockBase.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public interface IFriendInterlockAction
|
||||
{
|
||||
public Task<Result> doInterlockAction();
|
||||
public Task<(Result, FriendInterlockCacheRequest?)> doInterLockAndGetCache();
|
||||
}
|
||||
|
||||
public abstract class FriendInterlockBase : IFriendInterlockAction
|
||||
{
|
||||
private UserBase m_owner;
|
||||
private string m_my_guid;
|
||||
private string m_friend_guid;
|
||||
|
||||
public FriendInterlockBase(UserBase owner, string myGuid, string friendGuid)
|
||||
{
|
||||
m_owner = owner;
|
||||
m_my_guid = myGuid;
|
||||
m_friend_guid = friendGuid;
|
||||
}
|
||||
|
||||
public abstract Task<Result> doAction();
|
||||
|
||||
public async Task<(Result, FriendInterlockCacheRequest?)> doInterLockAndGetCache()
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var friend_cache_request = new FriendInterlockCacheRequest(m_owner, server_logic.getRedisConnector(), m_my_guid, m_friend_guid);
|
||||
var result = await friend_cache_request.getLock();
|
||||
if (result.isFail()) return (result, null);
|
||||
|
||||
result = await doAction();
|
||||
if (result.isFail()) return (result, null);
|
||||
|
||||
return (result, friend_cache_request);
|
||||
}
|
||||
|
||||
public async Task<Result> doInterlockAction()
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var player = m_owner as Player;
|
||||
var friend_cache_request = new FriendInterlockCacheRequest(m_owner, server_logic.getRedisConnector(), m_my_guid, m_friend_guid);
|
||||
var result = await friend_cache_request.getLock();
|
||||
if (result.isFail()) return result;
|
||||
|
||||
result = await doAction();
|
||||
if (result.isFail()) return result;
|
||||
|
||||
await friend_cache_request.removeFirstCache();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Player getOwner()
|
||||
{
|
||||
var owner = m_owner as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
protected string getMyGuid() => m_my_guid;
|
||||
protected string getFriendGuid() => m_friend_guid;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class RenameFriendFolderInterlockAction : FriendInterlockBase
|
||||
{
|
||||
private FriendAttribute m_friend_attrib;
|
||||
string m_new_folder_name;
|
||||
public RenameFriendFolderInterlockAction(UserBase owner, string myGuid, FriendAttribute friendAttibute, string newFolderName) : base(owner, myGuid, friendAttibute.FriendGuid)
|
||||
{
|
||||
m_friend_attrib = friendAttibute;
|
||||
m_new_folder_name = newFolderName;
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var player = getOwner();
|
||||
|
||||
var friend_agent_action = player.getEntityAction<FriendAgentAction>();
|
||||
|
||||
var friend = friend_agent_action.getFriend(getFriendGuid());
|
||||
NullReferenceCheckHelper.throwIfNull(friend, () => $"friend is null !!!");
|
||||
|
||||
var friend_attribute = friend.getEntityAttribute<FriendAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_attribute, () => $"friend_attribute is null !!!");
|
||||
friend_attribute.FolderName = m_new_folder_name;
|
||||
friend_attribute.modifiedEntityAttribute();//이것도 안해도될듯
|
||||
|
||||
return new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class ReplyFriendRequestLockAction : FriendInterlockBase
|
||||
{
|
||||
private Int32 m_reply_type = 1;
|
||||
public ReplyFriendRequestLockAction(UserBase owner, string myGuid, string friendGuid, int replyType) : base(owner, myGuid, friendGuid)
|
||||
{
|
||||
m_reply_type = replyType;
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var action = getOwner().getEntityAction<ReplyReceivedFriendRequestAction>();
|
||||
|
||||
var result = await action.replyReceivedFriendRequest(getMyGuid(), getFriendGuid(), m_reply_type);
|
||||
if (result.isFail()) return result;
|
||||
|
||||
//거절은 딱히 DB 수정할것 없다.
|
||||
if(m_reply_type == (int)FriendRequestReplyType.Accept)
|
||||
{
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(getOwner(), LogActionType.FriendAdd, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQAddFriend(getOwner().getUserGuid(), getFriendGuid()));
|
||||
}
|
||||
var log_invoker = new AddFriendBusinessLog(getOwner().getUserGuid(), getFriendGuid());
|
||||
batch.appendBusinessLog(log_invoker);
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
}
|
||||
|
||||
//거절 로그
|
||||
if (m_reply_type == (int)FriendRequestReplyType.Refuse)
|
||||
{
|
||||
//log
|
||||
List<ILogInvoker> invokers = new List<ILogInvoker>();
|
||||
invokers.Add(new RefuseFriendRequestBusinessLog(getMyGuid(), getFriendGuid()));
|
||||
var log_action = new LogActionEx(LogActionType.RefuseFriendRequest);
|
||||
BusinessLogger.collectLogs(log_action, getOwner(), invokers);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class SendFriendRequestInterlockAction : FriendInterlockBase
|
||||
{
|
||||
private DateTime m_request_time;
|
||||
public SendFriendRequestInterlockAction(UserBase owner, string myGuid, string friendGuid, DateTime requestTime) : base(owner, myGuid,friendGuid)
|
||||
{
|
||||
m_request_time = requestTime;
|
||||
}
|
||||
|
||||
public override async Task<Result> doAction()
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
DateTime now = DateTimeHelper.Current;
|
||||
|
||||
var friend_request_cache = new FriendReqCacheRequest(owner, getMyGuid(), getFriendGuid(), server_logic.getRedisConnector());
|
||||
var result = await friend_request_cache.addFriendRequest(owner.getUserGuid(), getFriendGuid(), now);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user