/* @ url : SyncMovement * @ request : * posX * posY * opponentUid * @ response : * opponentPosX * opponentPosY */ StructRequest SyncMovement(StructRequest request) { string user_id = request.uid; // 유저가 없을 때 if (!mUserData.ContainsKey(user_id)) { return(ServerNet.ErrorStructRequest()); } StructUserData user_data = mUserData[user_id]; // 파라매터가 오지 않았을 경우 if (request.parameter == null) { return(ServerNet.ErrorStructRequest()); } // 유저 위치 기록 if (request.parameter.ContainsKey("posX")) { user_data.posX = request.parameter["posX"]; } if (request.parameter.ContainsKey("posY")) { user_data.posY = request.parameter["posY"]; } if (request.parameter.ContainsKey("opponentUid")) { user_data.opponentUid = request.parameter["opponentUid"]; } mUserData[user_id] = user_data; // 상대방 정보 if (!request.parameter.ContainsKey("opponentUid")) { return(ServerNet.ErrorStructRequest()); } string opponentUid = request.parameter["opponentUid"]; // 상대방 정보 없을 경우 if (!mUserData.ContainsKey(opponentUid)) { return(ServerNet.ErrorStructRequest()); } StructUserData opponent_data = mUserData[opponentUid]; // 상대방 위치를 response로 전달 Dictionary <string, string> dic_param = new Dictionary <string, string>(); dic_param["opponentPosX"] = opponent_data.posX == null ? "0" : opponent_data.posX; dic_param["opponentPosY"] = opponent_data.posY == null ? "0" : opponent_data.posY; return(MakeResponse(request, dic_param)); }
/* @ url : GetOpponentData * @ request : * @ response : * opponentUid */ StructRequest GetOpponentData(StructRequest request) { string user_uid = request.uid; string opponent_uid = ErrorCode.Error.ToString(); if (user_uid == "1") { opponent_uid = "0"; } else { opponent_uid = "1"; } if (mUserData.ContainsKey(opponent_uid)) { StructUserData opponent_data = mUserData[opponent_uid]; Dictionary <string, string> dic_param = new Dictionary <string, string>(); dic_param["opponentUid"] = opponent_data.uid; return(MakeResponse(request, dic_param)); } return(ServerNet.ErrorStructRequest()); }