/// <summary> /// 패킷 아이디 얻는 유틸리티 함수 /// </summary> /// <param name="packet">The packet.</param> /// <returns></returns> public string ParserPacketID(string packet) { if (string.IsNullOrEmpty(packet) || base.State != eSocketState.Connected) { return(""); } xLitJson.JsonData data = xLitJson.JsonMapper.ToObject(packet); return((string)data[APIKEY_CMD]); }
/// <summary> /// 전송패킷의 응답 채크및 콜백 처리후에 삭제처리 /// </summary> /// <param name="msg">The MSG.</param> /// <returns></returns> private bool PopRemoveQueue(string msg) { bool rqPacket = false; xLitJson.JsonData data = xLitJson.JsonMapper.ToObject(msg); string packetId = (string)data[APIKEY_CMD]; for (int i = 0; i < _packetQueue.Count; i++) { if (_packetQueue[i].id.Equals(packetId)) { _packetQueue[i].responseCallback(packetId, msg); _packetQueue.RemoveAt(i); rqPacket = true; break; } } return(rqPacket); }
private void ReceiveParserCommand(Hashtable has) { string _id = has["id"].ToString(); switch (_id) { case eEventIDs.SocketConnect: case eEventIDs.SocketDisconnected: case eEventIDs.SocketStateChanged: case eEventIDs.SocketError: if (_socketEvent != null) { _socketEvent(_id, ""); } break; case eEventIDs.SocketData: { string msg = has["msg"].ToString(); #if UNITY_EDITOR || LOCAL_DEBUG if (logShow) { xLitJson.JsonData data = xLitJson.JsonMapper.ToObject(msg); string id = (string)data[APIKEY_CMD]; Debug.Log(_address.Port + "<Color=#30C0FF>ReceiveData >> id: " + id + " > packet </Color> " + msg); } #endif if (!PopRemoveQueue(msg)) { if (_receivePacket != null) { _receivePacket(msg); } } } break; } _ReceiveSchedule.remove(_id); }