// 2. 다른 유저 랭크 불러오기 public void GetRtRank(int index, int count) { try { SendQueue.Enqueue(Backend.RTRank.GetRTRankByUuid, ReturnUUID(index), count, callback => { GetRtRank_result = callback.IsSuccess(); if (!callback.IsSuccess() || callback.IsServerError()) { restartIndex_getUserRank = index; GetRtRank_queue = true; GetRtRank_queue_fail = true; return; } else if (callback.IsSuccess()) { data = callback.GetReturnValuetoJSON()["rows"]; GetRtRank_queue = true; } }); } catch (System.Exception e) { GameManager.SaveLogToServer("유저 랭킹 정보 가져오기 에러 발생", e.ToString(), "에러"); } }
// 갱신 private void UpdateRTRankTable(string cloumn, double value) { isRtScoreIndate = false; currColumn = cloumn; if (SaveManager.instance.indate_cha.Equals(string.Empty)) { Debug.Log("Indate가 존재하지 않습니다."); return; } try { SendQueue.Enqueue(Backend.GameInfo.UpdateRTRankTable, "character", cloumn, (long)value, SaveManager.instance.indate_cha, callback => { if (!callback.IsSuccess() || callback.IsServerError()) { UpdateRTRankTable_queue_fail = true; return; } else if (callback.IsSuccess()) { //currIndex = index; UpdateRTRankTable_queue = true; isRtScoreIndate = true; } }); } catch (System.Exception e) { Debug.Log("랭크업데이트 catch *********************"); //if (cloumn != "bossDungeonStage") // RestartRanking(); GameManager.SaveLogToServer(string.Format("{0} 랭킹 업데이트 에러 발생", cloumn), e.ToString(), "에러"); } }
// 1. 내 링크 불러오기 public void GetMyRTRank(int index) { try { SendQueue.Enqueue(Backend.RTRank.GetMyRTRank, ReturnUUID(index), 0, callback => { rankIndex = index; GetMyRTRank_result = callback.IsSuccess(); if (!callback.IsSuccess() || callback.IsServerError()) { restartIndex_getMyRank = index; GetMyRTRank_queue_fail = true; GetMyRTRank_queue = true; } else { myData = callback.GetReturnValuetoJSON()["rows"]; GetMyRTRank_queue = true; } }); } catch (System.Exception e) { GameManager.SaveLogToServer("내 랭킹 정보 가져오기 에러 발생", e.ToString(), "에러"); } }
public void LoadCard() { SendQueue.Enqueue(Backend.GameInfo.GetPrivateContents, "CardData", 2, callback => { if (callback.IsSuccess()) { if (callback.Rows().Count == 0) { Debug.Log("로드 정보 실패"); AddCard(); } else { Debug.Log("상점 로드 성공"); for (int i = 0; i < callback.Rows()[0]["CardKind"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.cardKind.Add(Convert.ToInt32(callback.Rows()[0]["CardKind"]["L"][i]["N"].ToString())); } for (int i = 0; i < callback.Rows()[0]["CardCound"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.cardCount.Add(Convert.ToInt32(callback.Rows()[0]["CardCound"]["L"][i]["N"].ToString())); } BackEndServerManager.instance.myCardDataIndate = callback.Rows()[0]["inDate"]["S"].ToString(); } } }); }
public void LoadChest() { SendQueue.Enqueue(Backend.GameInfo.GetPrivateContents, "ChestData", 5, callback => { if (callback.IsSuccess()) { if (callback.Rows().Count == 0) { Debug.Log("로드 정보 실패"); AddChest(); } else { Debug.Log("상자 로드 성공"); for (int i = 0; i < callback.Rows()[0]["ChestKind"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.haveChestKind.Add(Convert.ToInt32(callback.Rows()[0]["ChestKind"]["L"][i]["N"].ToString())); } for (int i = 0; i < callback.Rows()[0]["ChestState"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.haveChestState.Add(Convert.ToInt32(callback.Rows()[0]["ChestState"]["L"][i]["N"].ToString())); } BackEndServerManager.instance.myInfo.disStartTime = callback.Rows()[0]["StartTime"]["S"].ToString(); BackEndServerManager.instance.myInfo.disChest = Convert.ToInt32(callback.Rows()[0]["DisChest"]["N"].ToString()); BackEndServerManager.instance.myInfo.haveChests = Convert.ToInt32(callback.Rows()[0]["HaveChests"]["N"].ToString()); BackEndServerManager.instance.myChestDataIndate = callback.Rows()[0]["inDate"]["S"].ToString(); } } }); }
private static void CaptureDownloadFileReady(RequestWrapper request) { var connection = request.Connection; var payload = request.Request as C2S_DownloadFileReady; if (payload == null || !connection.Authorized(DfsPermissions.DownloadFile)) { request.TrySendResponse(S2C_DownloadFileResult.Failed, out _); return; } var fileId = connection.Data.Get <string>($"F_{payload?.BufferId}", null); if (fileId == null) { request.TrySendResponse(S2C_DownloadFileResult.Failed, out _); return; } connection.Data[$"F_{payload.BufferId}"] = null; var path = PathHelper.MapLocal(fileId, Config.Dfs.Path); SendQueue.Enqueue(new SendFileItem { FileStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete), Request = request, BufferId = payload.BufferId }, (int)connection.Identifier + payload.BufferId); }
public void LoadChart() { // 모든 캐릭터 정보 SendQueue.Enqueue(Backend.Chart.GetChartContents, "13704", callback => { if (callback.IsSuccess()) { for (int i = 0; i < callback.GetReturnValuetoJSON()["rows"].Count; i++) { Debug.Log("캐릭터 차트 불러오는 중 ... : " + i); BackEndServerManager.instance.myInfo.pName.Add(callback.GetReturnValuetoJSON()["rows"][i]["Name"]["S"].ToString()); BackEndServerManager.instance.myInfo.pMaxHp.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["Hp"]["S"].ToString())); BackEndServerManager.instance.myInfo.pCurHp.Add(BackEndServerManager.instance.myInfo.pMaxHp[i]); BackEndServerManager.instance.myInfo.pArmor.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["Armor"]["S"].ToString())); BackEndServerManager.instance.myInfo.pStamina.Add(100); BackEndServerManager.instance.myInfo.pMaxStamina.Add(100); BackEndServerManager.instance.myInfo.pReductionStamina.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["ReductionStamina"]["S"].ToString())); BackEndServerManager.instance.myInfo.pWeakAttackDamage.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["WeakAttack_Damage"]["S"].ToString())); BackEndServerManager.instance.myInfo.pWeakAttackStun.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["WeakAttack_Stun"]["S"].ToString())); BackEndServerManager.instance.myInfo.pWeakAttackPenetration.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["WeakAttack_ArmorPenetration"]["S"].ToString())); BackEndServerManager.instance.myInfo.pStrongAttackDamage.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["StrongAttack_Damage"]["S"].ToString())); BackEndServerManager.instance.myInfo.pStrongAttackStun.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["StrongAttack_Stun"]["S"].ToString())); BackEndServerManager.instance.myInfo.pStrongAttackPenetration.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["StrongAttack_ArmorPenetration"]["S"].ToString())); BackEndServerManager.instance.myInfo.pDefenseReceivingDamage.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["Defense_ReceivingDamage"]["S"].ToString())); BackEndServerManager.instance.myInfo.pDefenseReductionStun.Add(Convert.ToDouble(callback.GetReturnValuetoJSON()["rows"][i]["Defense_ReductionStun"]["S"].ToString())); } SetStats(); } }); }
public void AddChest() { BackEndServerManager.instance.myInfo.haveChestKind.InsertRange(index: 0, collection: new List <int>() { 99, 99, 99 }); BackEndServerManager.instance.myInfo.haveChestState.InsertRange(index: 0, collection: new List <int>() { 99, 99, 99 }); param = new Param(); param.Add("ChestKind", BackEndServerManager.instance.myInfo.haveChestKind); param.Add("ChestState", BackEndServerManager.instance.myInfo.haveChestState); param.Add("StartTime", BackEndServerManager.instance.myInfo.disStartTime); param.Add("DisChest", BackEndServerManager.instance.myInfo.disChest); param.Add("HaveChests", BackEndServerManager.instance.myInfo.haveChests); SendQueue.Enqueue(Backend.GameInfo.Insert, "ChestData", param, callback => { if (callback.IsSuccess()) { Debug.Log("상자 정보 추가성공"); } }); }
public void Queue(IEnumerable <BaseScertMessage> messages) { foreach (var message in messages) { SendQueue.Enqueue(message); } }
/// <summary> /// Sends the data to the remote endpoint. /// </summary> /// <param name="connectionId">The connection identifier.</param> /// <param name="data">The data.</param> public Task SendDataAsync(Guid connectionId, ArraySegment <byte> data) { #if false using (var memoryStream = new MemoryStream()) { using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, false)) { deflateStream.Write(data.Array, data.Offset, data.Count); } data = new ArraySegment <byte>(memoryStream.ToArray()); } var message = new DataMessage { ConnectionId = connectionId, CompressionMode = DataCompressionMode.Deflate, Data = data }; #else var message = new DataMessage { ConnectionId = connectionId, CompressionMode = DataCompressionMode.None, Data = data }; #endif SendQueue.Enqueue(message); return(Task.CompletedTask); }
public override void SendMessage(int msgID, byte[] msg) { if (msg == null) { throw new Exception("msgData can not be null"); } SendQueue.Enqueue(Packet.Encode(msgID, msg, mHasHeader)); }
public void SendDatagram([NotNull] SendDatagram datagram) { if (datagram == null) { throw new ArgumentNullException(nameof(datagram)); } SendQueue.Enqueue(datagram); }
public void LoadPoint() { SendQueue.Enqueue(Backend.GameSchemaInfo.Get, "Point", BackEndServerManager.instance.myUserDataIndate, callback => { Debug.Log("Point : " + Convert.ToInt32(callback.Rows()[0]["Score"]["N"].ToString())); BackEndServerManager.instance.myInfo.point = Convert.ToInt32(callback.Rows()[0]["Score"]["N"].ToString()); BackEndServerManager.instance.myPointDataIndate = callback.Rows()[0]["inDate"]["S"].ToString(); }); }
public void EnqueueSend <T>(T data) { if (Closed) { return; } SendQueue.Enqueue(packetDataSerializer.Deserialize <T>(data)); }
public void EnqueueTest() { SendQueue target = new SendQueue(); // TODO: 初始化为适当的值 byte[] byteBuffer = null; // TODO: 初始化为适当的值 long iOffset = 0; // TODO: 初始化为适当的值 long iLength = 0; // TODO: 初始化为适当的值 target.Enqueue(byteBuffer, iOffset, iLength); Assert.Inconclusive("无法验证不返回值的方法。"); }
public void SendPackage(Packet p) { if (p != null) { if (_log.IsInfoEnabled) { _log.InfoFormat("Sending Data to server: {0}", p.PacketType.ToString()); } SendQueue.Enqueue(p.GetBytes()); mreSender.Set(); } }
public override void SendMessage(int msgID, byte[] msg) { if (msg == null) { throw new Exception("msgData can not be null"); } if (!NetworkManager.NetEnabled) { return; } SendQueue.Enqueue(Packet.Encode(msgID, msg, _IsHeader)); }
public void LoadNotification(bool isStart) { if (loadNot.Count > 0) { loadNot.Clear(); } var i = 0; string offset = ""; loadNot.Add(Backend.Notice.NoticeList()); if (loadNot[i].IsSuccess()) { try { offset = loadNot[i].LastEvaluatedKeyString(); if (!string.IsNullOrEmpty(offset)) { SendQueue.Enqueue(Backend.Notice.NoticeList, 10, offset, callback => { loadNot.Add(callback); }); } OnClickLatestButton(); SettingBeforeList(); isStarttmp = isStart; if (isStart) { dontOpenDuringTheDayToggle.gameObject.SetActive(true); } else { dontOpenDuringTheDayToggle.gameObject.SetActive(false); } notificationPopUp.SetActive(true); } catch (System.Exception) { if (!isStart) { notNotificationPopUp.SetActive(true); } } //catch (System.Exception) //{ // //} isLoadDone = true; } }
public void GetMyMatchRecord(int index, Action <MatchRecord, bool> func) { var inDate = BackEndServerManager.instance.myIndate; SendQueue.Enqueue(Backend.Match.GetMatchRecord, inDate, matchInfos[index].matchType, matchInfos[index].matchModeType, matchInfos[index].inDate, callback => { MatchRecord record = new MatchRecord(); record.matchTitle = matchInfos[index].title; record.matchType = matchInfos[index].matchType; record.modeType = matchInfos[index].matchModeType; if (!callback.IsSuccess()) { Debug.LogError("매칭 기록 조회 실패\n" + callback); func?.Invoke(record, false); return; } if (callback.Rows().Count <= 0) { Debug.Log("매칭 기록이 존재하지 않습니다.\n" + callback); func?.Invoke(record, true); return; } var data = callback.Rows()[0]; var win = Convert.ToInt32(data["victory"]["N"].ToString()); var draw = Convert.ToInt32(data["draw"]["N"].ToString()); var defeat = Convert.ToInt32(data["defeat"]["N"].ToString()); var numOfMatch = win + draw + defeat; string point = string.Empty; if (matchInfos[index].matchType == MatchType.MMR) { point = data["mmr"]["N"].ToString(); } else if (matchInfos[index].matchType == MatchType.Point) { point = data["point"]["N"].ToString() + " P"; } else { point = "-"; } record.win = win; record.numOfMatch = numOfMatch; record.winRate = Math.Round(((float)win / numOfMatch) * 100 * 100) / 100; record.score = point; func?.Invoke(record, true); }); }
// 게임을 킬 때 사용하는 함수 public void Load(string table = "UserData") { SendQueue.Enqueue(Backend.GameInfo.GetPrivateContents, table, 7, callback => { if (callback.IsSuccess()) { if (callback.Rows().Count == 0) { Debug.Log("로드 정보 실패"); Add(); return; } else { BackEndServerManager.instance.myInfo.gold = Convert.ToInt32(callback.Rows()[0]["Gold"]["N"].ToString()); BackEndServerManager.instance.myInfo.diamond = Convert.ToInt32(callback.Rows()[0]["Diamond"]["N"].ToString()); BackEndServerManager.instance.myInfo.ads = Convert.ToBoolean(callback.Rows()[0]["Ads"]["BOOL"].ToString()); BackEndServerManager.instance.myInfo.pack = Convert.ToBoolean(callback.Rows()[0]["Pack"]["BOOL"].ToString()); BackEndServerManager.instance.myInfo.nowCharacter = Convert.ToInt32(callback.Rows()[0]["NowCharacter"]["N"].ToString()); BackEndServerManager.instance.myInfo.joinTime = callback.Rows()[0]["JoinTime"]["S"].ToString(); for (int i = 0; i < callback.Rows()[0]["HaveCharacters"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.haveCharacters.Add(Convert.ToInt32(callback.Rows()[0]["HaveCharacters"]["L"][i]["N"].ToString())); } for (int i = 0; i < callback.Rows()[0]["CharacterLevel"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.charactersLevel.Add(Convert.ToInt32(callback.GetReturnValuetoJSON()["rows"][0]["CharacterLevel"]["L"][i]["N"].ToString())); } for (int i = 0; i < callback.Rows()[0]["LevelExp"]["L"].Count; i++) { BackEndServerManager.instance.myInfo.levelExp.Add(Convert.ToInt32(callback.Rows()[0]["LevelExp"]["L"][i]["N"].ToString())); } BackEndServerManager.instance.myUserDataIndate = callback.Rows()[0]["inDate"]["S"].ToString(); LoadPoint(); LoadChest(); LoadCard(); LoadChart(); var errorLog = string.Format("로드완료 !\n이름 : {0}\n골드 : {1}\n광고 : {2}\nMMR : {3}", BackEndServerManager.instance.myNickName, BackEndServerManager.instance.myInfo.gold, BackEndServerManager.instance.myInfo.ads, BackEndServerManager.instance.myInfo.point); Debug.Log(errorLog); } } else { Debug.Log("로드 정보 실패"); Add(); } }); }
//--------------------------------------------------------------------------------------------------- /** 添加消息到发送队列 */ public override void SendMessage(int msgId, PacketDistributed msg) { //try //{ if (!NetworkManager.NetEnabled) { return; } SendQueue.Enqueue(Packet.Encode(msgId, msg, ServerMsgType, _IsHeader)); //} //catch (Exception e) //{ // Debug.LogError("Socket Send Message Exception " + e.Message); //} }
/// <summary> /// Enqueue a item to be sent, if there are threads available, a new sending thread will be started /// </summary> /// <typeparam name="T"></typeparam> /// <param name="Item"></param> public void EnqueueSend <T>(T Item) where T : Hashable { if (!Initilized) { throw new InvalidOperationException("The peer has not been initialized"); } sendCache.AddOrUpdate(Item.ComputedHash, Item, ConnectTimeOut); SendQueue.Enqueue(Item.ComputedHash); if (MaxSendingThreads < sendingThreads) { Task.Run(() => ProcessSendQueue()); } }
/// <summary> /// 创建消息包数据结构,并压入等待发送的消息队列中 /// </summary> /// <param name="msgID">消息包协议号</param> /// <param name="msgData">消息对象</param> public override void SendMessage(int msgID, PacketDistributed msgData) { try { if (msgData == null) { throw new Exception("msgData can not be null"); } SendQueue.Enqueue(Packet.Encode(msgID, msgData, ServerMsgType, mHasHeader)); } catch (Exception ex) { Debug.LogError("HttpObject SendMessage Exception: " + ex.Message); } }
/// <summary> /// 将消息添加到消息发送队列. /// </summary> /// <param name="myQQ"></param> /// <param name="sm"></param> private void AddSendQueue(string myQQ, SendMsg sm) { lock (_SendLock) { if (_SendMap.ContainsKey(myQQ)) { SendQueue sq = _SendMap[myQQ]; sq.Enqueue(sm); } else { SendQueue sq = new SendQueue(); sq.Enqueue(sm); _SendMap.Add(myQQ, sq); StartTask(myQQ); } } }
/// <summary> /// The timer will send a required PingPacket every 5 seconds by using this function /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnPingTimerElapsed(object sender, ElapsedEventArgs e) { // make sure to stop timPing.Stop(); // sanity check cause this is async if (isRunning) { // enqueue a ping message for sending SendQueue.Enqueue(new PingMessage()); // save time ping was sent lastPingSent = DateTime.Now; // start again timPing.Start(); } }
private IEnumerator Start() { yield return(new WaitUntil(() => LoadManager.instance.isDataLoaded)); yield return(new WaitUntil(() => QueueManager.instance.isQueueSet)); SendQueue.Enqueue(Backend.RTRank.GetMyRTRank, ReturnUUID(0), 0, callback => { if (!callback.IsSuccess()) { myStat_saved = 0; } else { LitJson.JsonData myData = callback.GetReturnValuetoJSON()["rows"]; myStat_saved = double.Parse(myData[0]["score"]["N"].ToString()); } }); }
internal void Send(byte[] data) { if (!_closed) { bool doNotify = false; lock (SendQueue) { SendQueue.Enqueue(data); if (SendQueue.Count == 1) { doNotify = true; } } if (doNotify) { OnGotDataToSend(); } } }
private void Send(Message message) { if (!Transport.Connected) { SendQueue.Enqueue(message); Connect(); } else if (Status != ConnectionStatus.Connecting || Status == ConnectionStatus.Connecting && (message.Command == "INIT" || message.Command == "MD")) { var args = new SocketAsyncEventArgs(); var buffer = Encoding.UTF8.GetBytes(message.ToString()); args.SetBuffer(buffer, 0, buffer.Length); args.Completed += Transport_Sent; Transport.SendAsync(args); App.ViewModel.AddDebugLog(string.Format(">{0}", message.ToString())); } else { SendQueue.Enqueue(message); } }
internal void EnqueueSend(DhtMessage message, Node node, IPEndPoint endpoint, TaskCompletionSource <SendQueryEventArgs> tcs = null) { if (message.TransactionId == null) { if (message is ResponseMessage) { throw new ArgumentException("Message must have a transaction id"); } do { message.TransactionId = TransactionId.NextId(); } while (DhtMessageFactory.IsRegistered(message.TransactionId)); } // We need to be able to cancel a query message if we time out waiting for a response if (message is QueryMessage) { DhtMessageFactory.RegisterSend((QueryMessage)message); } SendQueue.Enqueue(new SendDetails(node, endpoint, message, tcs)); }
public void AddCard() { BackEndServerManager.instance.myInfo.cardKind.InsertRange(index: 0, collection: new List <int>() { 99, 99, 99 }); BackEndServerManager.instance.myInfo.cardCount.InsertRange(index: 0, collection: new List <int>() { 99, 99, 99 }); param = new Param(); param.Add("CardKind", BackEndServerManager.instance.myInfo.cardKind); param.Add("CardCound", BackEndServerManager.instance.myInfo.cardCount); SendQueue.Enqueue(Backend.GameInfo.Insert, "CardData", param, callback => { if (callback.IsSuccess()) { Debug.Log("상점 정보 추가성공"); } }); }