public static CombatQuad newFromSFSObject(ISFSObject sfso) { CombatQuad combatQuad = new CombatQuad(sfso.GetByte("id")); combatQuad.posx = sfso.GetShort("px"); combatQuad.posy = sfso.GetShort("py"); combatQuad.energyLevel = sfso.GetByte("el"); combatQuad.bulletCount = sfso.GetByte("bc"); return(combatQuad); }
// Response private static bool SFDispatchRequestPatch(ref ISFSObject __0) { ISFSObject raw = __0; bool log = true; // System if (raw.GetByte("c") == 0) { ISFSObject p = raw.GetSFSObject("p"); // Player movements int a = Convert.ToInt32(raw.GetShort("a")); if (a == 1000 || a == 1002 || a == 1004 || a == 11 || a == 12) { log = false; } } // Game else if (raw.GetByte("c") == 1) { ISFSObject p = raw.GetSFSObject("p"); if (p.GetUtfString("c") == "GameStart") { ISFSObject p2 = p.GetSFSObject("p"); //NetworkMonster monster1 = p2.GetSFSArray("teamMonsters").GetClass(0) as NetworkMonster; //monster1.luma = true; //monster1.Nickname = "gay"; //p2.PutUtfString("nck", "nitro."); //p2.PutInt("tid", 1337); } // Player movements int a = Convert.ToInt32(raw.GetShort("a")); //if (a == 1000 || a == 1002 || a == 1004 || a == 11) log = false; if (a == 13) { string c = p.GetUtfString("c"); if (c == "UPP" || c.StartsWith("PA.")) { log = false; } } } if (log) { Logger.LogLine($"Receiving message (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Cyan); } return(true); }
private void SetPlayerInfo(ISFSObject userData) { if (userData.ContainsKey("ip")) { IpLabel.text = userData.GetUtfString("ip"); } if (userData.ContainsKey(RequestKey.KeyId)) { _pointSeadId = userData.GetInt(RequestKey.KeyId); IdLabel.text = _pointSeadId.ToString(CultureInfo.InvariantCulture); } if (userData.ContainsKey(RequestKey.KeyName)) { NameLabel.text = userData.GetUtfString(RequestKey.KeyName); } if (userData.ContainsKey(NewRequestKey.KeyAvatar)) { short sex = 0; if (userData.ContainsKey(NewRequestKey.KeySex)) { sex = userData.GetShort(NewRequestKey.KeySex); } DDzUtil.LoadRealHeadIcon(userData.GetUtfString(NewRequestKey.KeyAvatar), sex, HeadTexture); } DetailInfoGob.SetActive(true); }
private void DispatchRequest(ISFSObject requestObject) { IMessage message = new Message(); if (requestObject.IsNull(CONTROLLER_ID)) { throw new SFSCodecError("Request rejected: No Controller ID in request!"); } if (requestObject.IsNull(ACTION_ID)) { throw new SFSCodecError("Request rejected: No Action ID in request!"); } message.Id = Convert.ToInt32(requestObject.GetShort(ACTION_ID)); message.Content = requestObject.GetSFSObject(PARAM_ID); message.IsUDP = requestObject.ContainsKey(UDP_PACKET_ID); if (message.IsUDP) { message.PacketId = requestObject.GetLong(UDP_PACKET_ID); } int @byte = requestObject.GetByte(CONTROLLER_ID); IController controller = bitSwarm.GetController(@byte); if (controller == null) { throw new SFSError("Cannot handle server response. Unknown controller, id: " + @byte); } controller.HandleMessage(message); }
public void HandleHandShake(BaseEvent evt) { ISFSObject iSFSObject = evt.Params["message"] as ISFSObject; if (iSFSObject.IsNull(BaseRequest.KEY_ERROR_CODE)) { sessionToken = iSFSObject.GetUtfString(HandshakeRequest.KEY_SESSION_TOKEN); socketClient.CompressionThreshold = iSFSObject.GetInt(HandshakeRequest.KEY_COMPRESSION_THRESHOLD); socketClient.MaxMessageSize = iSFSObject.GetInt(HandshakeRequest.KEY_MAX_MESSAGE_SIZE); if (debug) { log.Debug($"Handshake response: tk => {sessionToken}, ct => {socketClient.CompressionThreshold}"); } if (socketClient.IsReconnecting) { socketClient.IsReconnecting = false; DispatchEvent(new SFSEvent(SFSEvent.CONNECTION_RESUME)); return; } isConnecting = false; Hashtable hashtable = new Hashtable(); hashtable["success"] = true; DispatchEvent(new SFSEvent(SFSEvent.CONNECTION, hashtable)); } else { short @short = iSFSObject.GetShort(BaseRequest.KEY_ERROR_CODE); string errorMessage = SFSErrorCodes.GetErrorMessage(@short, log, iSFSObject.GetUtfStringArray(BaseRequest.KEY_ERROR_PARAMS)); Hashtable hashtable2 = new Hashtable(); hashtable2["success"] = false; hashtable2["errorMessage"] = errorMessage; hashtable2["errorCode"] = @short; DispatchEvent(new SFSEvent(SFSEvent.CONNECTION, hashtable2)); } }
// Request private static bool SFOnDataWritePatch(ref IMessage __0) { ISFSObject raw = __0.Content; bool log = true; // System if (raw.GetByte("c") == 0) { } // Game else if (raw.GetByte("c") == 1) { ISFSObject p = raw.GetSFSObject("p"); // Player movements string c = p.GetUtfString("c"); if (c == "spawnMonster") { ISFSObject p2 = p.GetSFSObject("p"); p2.PutBool("sp", true); } if (c == "UPP" || c == "playerAction.CM") { log = false; } } if (log) { Logger.LogLine($"Sending request (ID {Convert.ToInt32(raw.GetShort("a"))}):\n{raw.GetDump()}", ConsoleColor.Green); } return(true); }
public TtResultUserData(ISFSObject data) { UserId = data.GetInt("id"); UserName = data.GetUtfString("nick"); UserHead = data.GetUtfString("avatar"); UserGold = data.GetInt("gold"); Sex = data.GetShort("sex"); }
public ResultData(ISFSObject data) { Win = data.GetInt("win"); TtGold = data.GetLong("ttgold"); FoldScore = data.GetInt("foldScore"); Name = data.GetUtfString("name"); FoldCards = data.GetIntArray("foldCards"); Seat = data.GetInt("seat"); Sex = data.GetShort("sex"); Head = data.GetUtfString("avatar"); IsNoFold = data.GetBool("isNoFold"); }
public static void TryGetValueWitheKey(ISFSObject data, out short value, string key) { if (data.ContainsKey(key)) { value = data.GetShort(key); } else { value = 0; TryGetLog(key); } }
/// <summary> /// 设置用户信息 /// </summary> /// <param name="userData"></param> UserInfoStruct SetUserData(ISFSObject userData) { SetContryInfo(userData); var userinfoStruct = new UserInfoStruct(); if (userData.ContainsKey(RequestKey.KeyId)) { userinfoStruct.Id = userData.GetInt(RequestKey.KeyId); } if (userData.ContainsKey("ip")) { userinfoStruct.Ip = userData.GetUtfString("ip"); } if (userData.ContainsKey("country")) { userinfoStruct.Country = userData.GetUtfString("country"); } if (userData.ContainsKey(RequestKey.KeyName)) { userinfoStruct.Name = userData.GetUtfString(RequestKey.KeyName); } //获取gpsx; gpsy if ((userData.ContainsKey("gpsx") && userData.ContainsKey("gpsy")) || (userData.ContainsKey("x") && userData.ContainsKey("y"))) { userinfoStruct.GpsX = userData.ContainsKey("gpsx") ? userData.GetFloat("gpsx") : userData.GetFloat("x"); userinfoStruct.GpsY = userData.ContainsKey("gpsy") ? userData.GetFloat("gpsy") : userData.GetFloat("y"); } else { userinfoStruct.GpsX = -1f; userinfoStruct.GpsY = -1f; } if (userData.ContainsKey(NewRequestKey.KeyAvatar)) { userinfoStruct.HeadImgAvatar = userData.GetUtfString(NewRequestKey.KeyAvatar); } if (userData.ContainsKey(NewRequestKey.KeySex)) { userinfoStruct.Sex = userData.GetShort(NewRequestKey.KeySex); } return(userinfoStruct); }
private void InitPlayerHeadImage(ISFSObject data) { if (data.ContainsKey("avatar")) { PortraitDb.SetPortrait(data.GetUtfString("avatar"), _headImage, data.GetShort("sex")); } else { var userInfo = GetUserInfo(data.GetInt("seat")); if (userInfo == null) { return; } PortraitDb.SetPortrait(userInfo.AvatarX, _headImage, userInfo.SexI); } }
/// <summary> /// 设置玩家头像信息 /// </summary> /// <param name="userdata"></param> /// <param name="headTexture"></param> public static void SetUserHeadTexture(ISFSObject userdata, UITexture headTexture) { short sex = 0; if (userdata.ContainsKey(NewRequestKey.KeySex)) { sex = userdata.GetShort(NewRequestKey.KeySex); } if (userdata.ContainsKey(NewRequestKey.KeyAvatar)) { LoadRealHeadIcon(userdata.GetUtfString(NewRequestKey.KeyAvatar), sex, headTexture); } else { LoadDefaultHeadIcon(sex, headTexture); } }
//--------------------------------end /// <summary> /// 根据缓存的信息刷新用户信息ui /// </summary> public override void RefreshUiInfo() { if (UserDataTemp != null) { if (UserDataTemp.ContainsKey(RequestKey.KeyName)) { NameLabel.text = UserDataTemp.GetUtfString(RequestKey.KeyName); } if (UserDataTemp.ContainsKey(RequestKey.KeyId)) { IdLabel.text = UserDataTemp.GetInt(RequestKey.KeyId).ToString(CultureInfo.InvariantCulture); } short sex = 0; if (UserDataTemp.ContainsKey(NewRequestKey.KeySex)) { sex = UserDataTemp.GetShort(NewRequestKey.KeySex); } if (UserDataTemp.ContainsKey(NewRequestKey.KeyAvatar)) { DDzUtil.LoadRealHeadIcon(UserDataTemp.GetUtfString(NewRequestKey.KeyAvatar), sex, HeadTexture); } else { DDzUtil.LoadDefaultHeadIcon(sex, HeadTexture); } if (UserDataTemp.ContainsKey(NewRequestKey.KeyTtGold)) { ScoreLabel.text = UserDataTemp.GetLong(NewRequestKey.KeyTtGold).ToString(CultureInfo.InvariantCulture); } if (!App.GetGameData <GlobalData>().IsStartGame && UserDataTemp.ContainsKey(RequestKey.KeyState)) { GameReadySp.gameObject.SetActive(UserDataTemp.GetBool(RequestKey.KeyState)); } } }
public virtual void ParseData(ISFSObject userData) { name = userData.GetUtfString(RequestKey.KeyName); Seat = userData.GetInt(RequestKey.KeySeat); IsReady = userData.GetBool(RequestKey.KeyState); TotalGlod = userData.GetLong(RequestKey.KeyTotalGold); if (userData.ContainsKey(RequestKey.KeyGold)) { FloatGold = userData.GetLong(RequestKey.KeyGold); } Glod = TotalGlod + FloatGold; id = userData.GetInt(RequestKey.KeyId); Country = userData.GetUtfString(RequestKeyOther.Country); Sex = (short)(userData.GetShort(RequestKeyOther.Sex) % 2); WinTimes = userData.GetInt(RequestKeyOther.WinTime); LostTimes = userData.GetInt(RequestKeyOther.LostTime); TotalTimes = userData.GetInt(RequestKeyOther.TotalTime); level = userData.GetInt(RequestKeyOther.Level); SignText = userData.ContainsKey(RequestKeyOther.Signature) ? userData.GetUtfString(RequestKeyOther.Signature) : ""; string avatar = userData.ContainsKey(RequestKeyOther.Avatar) ? userData.GetUtfString(RequestKeyOther.Avatar) : ""; if (!string.IsNullOrEmpty(avatar)) { HeadImage = avatar; } ip = userData.GetUtfString(RequestKeyOther.Ip); if (userData.ContainsKey(RequestKeyOther.KeyNetWork)) { IsOutLine = !userData.GetBool(RequestKeyOther.KeyNetWork); } IsNull = false; if (userData.ContainsKey("jiaMa")) { Jiama = userData.GetInt("jiaMa"); } }
private void OnTtResult(object data) { ItemList.Clear(); JhGameTable GameData = App.GetGameData <JhGameTable>(); ISFSObject obj = (ISFSObject)data; ISFSArray usersArr = obj.GetSFSArray("users"); long time = obj.GetLong("svt"); for (int i = 0; i < usersArr.Count; i++) { ISFSObject objItem = usersArr.GetSFSObject(i); if (objItem.GetKeys().Length > 0) { var rItem = new TtResultItem { Name = objItem.GetUtfString("nick"), Avatar = objItem.GetUtfString("avatar"), Sex = objItem.GetShort("sex"), Gold = objItem.GetInt("gold"), WinCnt = objItem.GetInt("win"), LostCnt = objItem.GetInt("lose"), BipaiCnt = objItem.GetInt("abandon"), UId = objItem.GetInt("id") }; ItemList.Add(rItem); } } int bigWiner = 0; int cnt = 0; for (int i = 0; i < ItemList.Count; i++) { TtResultItem item = ItemList[i]; if (item.WinCnt > cnt) { bigWiner = i; cnt = item.WinCnt; } } ItemList[bigWiner].IsBigWinner = true; ISFSArray sendArr = SFSArray.NewInstance(); foreach (TtResultItem item in ItemList) { sendArr.AddSFSObject(item.GetSfsObj()); } ISFSObject sendObj = SFSObject.NewInstance(); sendObj.PutSFSArray("Users", sendArr); sendObj.PutUtfString("Time", DateTime.FromBinary(time).ToString()); sendObj.PutInt("MaxLun", GameData.maxRound); sendObj.PutInt("RoomID", GameData.CreateRoomInfo.RoomId); sendObj.PutInt("Ante", GameData.AnteRate[0]); sendObj.PutInt("Ju", GameData.CreateRoomInfo.CurRound); EventObj.SendEvent("TtResultViewEvent", "TtResultInfo", sendObj); }