public void TestClientInfo() { string clientid = "015186"; ClientData data = new ClientData(); ClientEntity result = data.GetClientInfo(clientid); Assert.IsNotNull(result, "No client data has been returned for {0}", clientid); Assert.AreEqual("Winston House, 349 Regents Park Road, Finchley, London", result.Address.Trim(), "Invalid value returned for Address"); Assert.AreEqual("Alan Mays", result.Contact.Trim(), "Invalid value returned for Contact"); Assert.AreEqual("OSMOND GAUT & ROSE", result.Name.Trim(), "Invalid value returned for Name"); Assert.AreEqual("N3 1DH", result.Postcode.Trim(), "Invalid value returned for Postcode"); Assert.AreEqual("015186", result.Refno.Trim(), "Invalid value returned for Refno"); clientid = "1907"; data = new ClientData(); result = data.GetClientInfo(clientid); Assert.IsNotNull(result, "No client data has been returned for {0}", clientid); Assert.AreEqual("15 DRINKWATER STREET,DOUGLAS,ISLE OF MAN", result.Address.Trim(), "Invalid value returned for Address"); Assert.AreEqual("M.B.MAJID", result.Contact.Trim(), "Invalid value returned for Contact"); Assert.AreEqual("REGAL ESTATES LTD", result.Name.Trim(), "Invalid value returned for Name"); Assert.AreEqual("IM1 1AT", result.Postcode.Trim(), "Invalid value returned for Postcode"); Assert.AreEqual("1907", result.Refno.Trim(), "Invalid value returned for Refno"); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); Initer.Init(@"Server=ADWA;Database=Hotel;Trusted_Connection=true"); var clientData = new ClientData("test", "test", "test", "test"); var client = new Client { ClientData = clientData }; var repo = new ClientRepository(); repo.Save(client); var features = new List<Feature>(); features.Add(Feature.Bathroom); var room = new Room { Quality = RoomQuality.Average, Features = features, Type = RoomType.HotelRoom }; room.SetCapacity(5); var roomRepo = new RoomRepository(); roomRepo.Save(room); var features2 = new List<Feature>(); features2.Add(Feature.Bathroom); features2.Add(Feature.Tv); var room2 = new Room { Quality = RoomQuality.Good, Features = features2, Type = RoomType.HotelRoom }; room2.SetCapacity(2); roomRepo.Save(room2); var duration = new DayDuration(DateTime.Now, DateTime.Now.AddDays(1)); var reservation = new Reservation(client, room, duration); var reservationRepo = new ReservationRepository(); reservationRepo.Save(reservation); }
public ClientData GetClientData(int playerId) { ClientData client = new ClientData(-1); if (!clients.TryGetValue (playerId, out client)) { Debug.LogError ("Can not find a ClientData for playerId: " + playerId); } return client; }
public override void RcvConnect(int rcvHostId, int connectionId, int channelId) { playersConnected++; textField.text = playersConnected + ""; ClientData client = new ClientData (connectionId); networkManager.AddClientData (client); CheckReady (); //TODO this is kind of an ugly hack to auto-ready; }
public int RegisterMailbox(MessageEvaluator evaluator) { var id = _nextId++; _clients[id] = new ClientData { Messages = new List<IIncomingEmailMessage>(), Evaluator = evaluator }; return id; }
public void Connect() { if (!tsClient.IsConnected) { tsClient.Connect(connectionData.host, connectionData.port); tsClient.Login(connectionData.user, connectionData.passwd); tsClient.UseServer(1); try { tsClient.ChangeName("TS3AudioBot"); } catch (QueryCommandException) { Log.Write(Log.Level.Warning, "TS3AudioBot name already in use!"); } me = GetSelf(); tsClient.RegisterNotification(MessageTarget.Server, -1); tsClient.RegisterNotification(MessageTarget.Private, -1); tsClient.RegisterNotification(RequestTarget.Server, -1); TickPool.RegisterTick(() => tsClient.WhoAmI(), PingInterval, true); } }
/// <summary> /// конструктор /// </summary> /// <param name="Original">оригинальный тест</param> /// <param name="client">интернет соединение</param> public Client(byte[] bytes,ref Test Original) { this.Buffer = bytes; this.OrigialTest = Original; this.Data = new ClientData(); if (SetIdentificationData(this.Buffer) == false) { throw new Exception(); } try { string FileString = UTF8Encoding.GetString(bytes); FileString = Regex.Replace(FileString, "\\0", ""); FileString = Regex.Replace(FileString, "#@END@#", ""); this.CurrentXml = XDocument.Parse(FileString); } catch { throw new Exception(); } }
public void SendResponse(ClientData clientData, NetworkStream stream) { ServerData serverData = new ServerData { Id = clientData.Id }; try { serverData.Text = Helper.ProcessClientData(clientData); serverData.Status = "Success"; } catch (Exception ex) { serverData.Text = ex.Message; serverData.Status = "Error"; } byte[] buffer = Helper.SdoSerializeServerData(serverData); stream.Write(buffer, 0, buffer.Length); stream.Flush(); }
private void CreateTabPage(ClientData item) { if (InvokeRequired) { Invoke( new CreateTabPageDelegate(CreateTabPage), item); } else { TabPage tp = new TabPage(item.ClientName); tp.Tag = item; UCChatControl uc = new UCChatControl(); tp.Controls.Add(uc); uc.Location = new Point(0, 0); uc.Dock = DockStyle.Fill; uc.CData = item; _ucChatControls.Add(item.ClientID, uc); tabControl1.TabPages.Add(tp); } }
public void AddClient([NotNull] ClientData client) { _settings.ClientsStore.AddClient(client); }
// Update and generate a game state snapshot private void updateState() { // If not on the server, bail if (!GetTree().IsNetworkServer()) { return; } // Initialize the "high level" snapshot Snapshot snapshot = new Snapshot(); snapshot.signature = snapshotSignature; foreach (KeyValuePair <int, NetworkPlayer> networkPlayer in network.networkPlayers) { // Node may not being created yet if (!HasNode("client_" + networkPlayer.Value.net_id)) { // Ideally should give a warning that a player node wasn't found continue; } // Locate the player's node. Even if there is no input/update, it's state will be dumped // into the snapshot anyway Player playerNode = (Player)GetNode("client_" + networkPlayer.Value.net_id); if (!IsInstanceValid(playerNode) || playerNode == null) { // Ideally should give a warning that a player node wasn't found continue; } Vector2 pPosition = playerNode.Position; float pRotation = playerNode.Rotation; // Check if there is any input for this player. In that case, update the state if (gameStates.playerInputs.ContainsKey(networkPlayer.Key) && gameStates.playerInputs[networkPlayer.Key].Count > 0) { bool primaryWeapon = false; bool secondaryWeapon = false; // Calculate the delta float delta = gameStates.updateDelta / (float)(gameStates.playerInputs[networkPlayer.Key].Count); foreach (KeyValuePair <int, GameStates.PlayerInput> input in gameStates.playerInputs[networkPlayer.Key]) { Vector2 moveDir = new Vector2(); if (input.Value.up) { moveDir.y = -1; } if (input.Value.down) { moveDir.y = 1; } if (input.Value.left) { moveDir.x = -1; } if (input.Value.right) { moveDir.x = 1; } primaryWeapon = input.Value.primaryWepaon; secondaryWeapon = input.Value.secondaryWepaon; if (input.Value.changePrimaryWeapon) { playerNode.changePrimaryWeapon(playerNode.currentPrimaryWeaponIndex + 1); } if (input.Value.changeSecondaryWeapon) { playerNode.changeSecondaryWeapon(playerNode.currentSecondaryWeaponIndex + 1); } playerNode._shoot(primaryWeapon, secondaryWeapon); playerNode.move(moveDir, input.Value.mousePosition, delta); } // Cleanup the input vector gameStates.playerInputs[networkPlayer.Key].Clear(); gameStates.playerInputs.Remove(networkPlayer.Key); ClientData clientData = new ClientData(); clientData.id = networkPlayer.Key + ""; clientData.position = playerNode.Position; clientData.rotation = playerNode.Rotation; clientData.primaryWepaon = primaryWeapon; clientData.secondaryWepaon = secondaryWeapon; clientData.primaryWeaponIndex = playerNode.currentPrimaryWeaponIndex; clientData.secondaryWeaponIndex = playerNode.currentSecondaryWeaponIndex; clientData.health = playerNode.getHealth(); snapshot.playerData.Add(networkPlayer.Key, clientData); } } // Clean the input gameStates.playerInputs.Clear(); Godot.Collections.Array <String> removeSpawnBots = new Godot.Collections.Array <String>(); foreach (SpawnBot spawnBot in spawnBots.Values) { // Locate the bot node Enemy enemyNode = (Enemy)GetNode(spawnBot.name); if (enemyNode == null) { // Ideally should give a warning that a bot node wasn't found continue; } enemyNode._shoot(enemyNode.isPrimaryWeapon, enemyNode.isSecondaryWeapon); if (enemyNode.getHealth() > 0) { // Build bot_data entry ClientData clientData = new ClientData(); clientData.id = spawnBot.name; clientData.position = enemyNode.GlobalPosition; clientData.rotation = enemyNode.GlobalRotation; clientData.health = enemyNode.getHealth(); clientData.primaryWepaon = enemyNode.isPrimaryWeapon; clientData.secondaryWepaon = enemyNode.isSecondaryWeapon; clientData.primaryWeaponIndex = enemyNode.currentPrimaryWeaponIndex; clientData.secondaryWeaponIndex = enemyNode.currentSecondaryWeaponIndex; // Append into the snapshot snapshot.botData.Add(spawnBot.name, clientData); } else { removeSpawnBots.Insert(0, spawnBot.name); } } foreach (String spawnBotId in removeSpawnBots) { removeClient(spawnBotId); } if (removeSpawnBots.Count > 0) { syncBots(-1); } // Encode and broadcast the snapshot - if there is at least one connected client if (network.networkPlayers.Count > 1) { encodeSnapshot(snapshot); } // Make sure the next update will have the correct snapshot signature snapshotSignature += 1; }
public void ReportSpeed(SpeedData message) { try { if (message == null) { return; } string minerIp = GetMinerIp(); ClientData clientData = HostRoot.Current.ClientSet.LoadClient(message.ClientId); if (clientData == null) { clientData = new ClientData() { Id = message.ClientId, MinerName = message.MinerName, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, MainCoinCode = message.MainCoinCode, MainCoinPool = message.MainCoinPool, MainCoinWallet = message.MainCoinWallet, Kernel = message.Kernel, IsDualCoinEnabled = message.IsDualCoinEnabled, DualCoinPool = message.DualCoinPool, DualCoinWallet = message.DualCoinWallet, DualCoinCode = message.DualCoinCode, IsMining = message.IsMining, MinerIp = minerIp }; HostRoot.Current.ClientSet.Add(clientData); } else { clientData.MinerName = message.MinerName; clientData.ModifiedOn = DateTime.Now; clientData.MainCoinCode = message.MainCoinCode; clientData.MainCoinPool = message.MainCoinPool; clientData.MainCoinWallet = message.MainCoinWallet; clientData.Kernel = message.Kernel; clientData.IsDualCoinEnabled = message.IsDualCoinEnabled; clientData.DualCoinPool = message.DualCoinPool; clientData.DualCoinWallet = message.DualCoinWallet; clientData.DualCoinCode = message.DualCoinCode; clientData.IsMining = message.IsMining; clientData.MinerIp = minerIp; } bool isMainCoin = !string.IsNullOrEmpty(message.MainCoinCode); // 认为双挖币不能和主挖币相同 bool isDualCoin = !string.IsNullOrEmpty(message.DualCoinCode) && message.DualCoinCode != message.MainCoinCode; if (isMainCoin) { HostRoot.Current.ClientCoinSnapshotSet.Add(new ClientCoinSnapshotData { CoinCode = message.MainCoinCode, ShareDelta = message.MainCoinShareDelta, Speed = message.MainCoinSpeed, Timestamp = DateTime.Now, ClientId = message.ClientId }); } if (isDualCoin) { HostRoot.Current.ClientCoinSnapshotSet.Add(new ClientCoinSnapshotData { CoinCode = message.DualCoinCode, ShareDelta = message.DualCoinShareDelta, Speed = message.DualCoinSpeed, Timestamp = DateTime.Now, ClientId = message.ClientId }); } } catch (Exception e) { Global.WriteLine(e.Message, ConsoleColor.Red); Global.WriteLine(e.StackTrace, ConsoleColor.Red); } }
protected void QueryBuilderControl1_SQLUpdated(object sender, EventArgs e, ClientData clientdata) { tbSQL.Text = QueryBuilderControl1.PlainTextSQLBuilder.SQL; }
static void testvfs_obj_del(ClientData cd){ Testvfs p = (Testvfs)cd; if ( p.pScript !=null) TCL.Tcl_DecrRefCount( ref p.pScript ); sqlite3_vfs_unregister(p.pVfs); Debugger.Break();//TODO //ckfree((char )p.pVfs); //ckfree((char )p); }
//internal void ResetPriorities(EndpointId endpointId) //{ // Debug.Assert(m_clientStates.ContainsKey(endpointId)); // foreach (var entry in m_clientStates[endpointId].StateGroups.Values) // { // entry.ResetPriority(); // } //} // Event dispatch: // 1) Reliable events are sent immediatelly when client has replicable or state group // 2) Unreliable events are added into queue with priority (they added only for relevant replicated objects or state groups) bool ShouldSendEvent(IMyNetObject eventInstance, bool isReliable, ClientData client, out float priority) { if (eventInstance == null) { // Static event priority = 1; return true; } MyStateDataEntry entry; MyReplicableClientData replicableInfo; if ((eventInstance is IMyStateGroup && client.StateGroups.TryGetValue((IMyStateGroup)eventInstance, out entry))) { // For state group, priority cannot be inherited, because it's changing with time // Maybe add another method IMyStateGroup.GetEventPriority() replicableInfo = client.Replicables[entry.Owner]; priority = 1; return isReliable || replicableInfo.HasActiveStateSync; } else if (eventInstance is IMyReplicable && (client.Replicables.TryGetValue((IMyReplicable)eventInstance, out replicableInfo) || m_fixedObjects.Contains(eventInstance))) { // Event inherits replicated object priority priority = ((IMyReplicable)eventInstance).GetPriority(client.State); return isReliable || (priority > 0 && replicableInfo.HasActiveStateSync); } else { priority = 0; return false; } }
public override void OnStartClient() { cData = new Model.ClientData(null, 0, 0, new Vector2()); sendCardData = new Model.ClientData(null, 0, 0, new Vector2()); }
public IEnumerable <Client> GetData(out int totalRecords, string globalSearch, bool?filterActive, int?limitOffset, int?limitRowCount, string orderBy, bool desc, string reptype) { IQueryable <Client> query; if (reptype.Equals("NoNicknames")) { query = ClientData.NoNicknames(); } else if (reptype.Equals("NoBirthday")) { query = ClientData.NoBirthdays(); } else if (reptype.Equals("NoMobile")) { query = ClientData.NoMobile(); } else if (reptype.Equals("NoMobileWithEmail")) { query = ClientData.NoMobileWithEmail(); } else if (reptype.Equals("WithMobile")) { query = ClientData.WithMobile(); } else if (reptype.Equals("WithMobileBday")) { query = ClientData.WithMobileBday(); } else if (reptype.Equals("WithMobileEmail")) { query = ClientData.WithMobileEmail(); } else { query = ClientData.BirthMonth(int.Parse(reptype.Split('-')[1])); } if (!String.IsNullOrWhiteSpace(globalSearch)) { query = query.Where(p => (p.ClientName).Contains(globalSearch)); } totalRecords = query.Count(); if (!String.IsNullOrWhiteSpace(orderBy)) { switch (orderBy.ToLower()) { case "title": query = (!desc) ? query.OrderBy(p => p.Title) : query.OrderByDescending(p => p.Title); break; case "lastname": query = (!desc) ? query.OrderBy(p => p.LastName) : query.OrderByDescending(p => p.LastName); break; case "firstname": query = (!desc) ? query.OrderBy(p => p.FirstName) : query.OrderByDescending(p => p.FirstName); break; case "middlename": query = (!desc) ? query.OrderBy(p => p.MiddleName) : query.OrderByDescending(p => p.MiddleName); break; case "nickname": query = (!desc) ? query.OrderBy(p => p.NickName) : query.OrderByDescending(p => p.NickName); break; case "clientname": query = (!desc) ? query.OrderBy(p => p.ClientName) : query.OrderByDescending(p => p.ClientName); break; case "clienttype": query = (!desc) ? query.OrderBy(p => p.ClientType) : query.OrderByDescending(p => p.ClientType); break; case "officeaddress": query = (!desc) ? query.OrderBy(p => p.OfficeAddress) : query.OrderByDescending(p => p.OfficeAddress); break; case "homeaddress": query = (!desc) ? query.OrderBy(p => p.HomeAddress) : query.OrderByDescending(p => p.HomeAddress); break; case "mailingaddress": query = (!desc) ? query.OrderBy(p => p.MailingAddress) : query.OrderByDescending(p => p.MailingAddress); break; case "dateofbirth": query = (!desc) ? query.OrderBy(p => p.DateofBirth) : query.OrderByDescending(p => p.DateofBirth); break; case "clientage": query = (!desc) ? query.OrderBy(p => p.ClientAge) : query.OrderByDescending(p => p.ClientAge); break; case "contactno": query = (!desc) ? query.OrderBy(p => p.ContactNo) : query.OrderByDescending(p => p.ContactNo); break; case "referredby": query = (!desc) ? query.OrderBy(p => p.ReferredBy) : query.OrderByDescending(p => p.ReferredBy); break; case "mobile": query = (!desc) ? query.OrderBy(p => p.Mobile) : query.OrderByDescending(p => p.Mobile); break; case "phone": query = (!desc) ? query.OrderBy(p => p.Phone) : query.OrderByDescending(p => p.Phone); break; case "email": query = (!desc) ? query.OrderBy(p => p.Email) : query.OrderByDescending(p => p.Email); break; case "createdby": query = (!desc) ? query.OrderBy(p => p.Createdby) : query.OrderByDescending(p => p.Createdby); break; case "createdate": query = (!desc) ? query.OrderBy(p => p.Createdate) : query.OrderByDescending(p => p.Createdate); break; case "updatedby": query = (!desc) ? query.OrderBy(p => p.Updatedby) : query.OrderByDescending(p => p.Updatedby); break; case "updatedate": query = (!desc) ? query.OrderBy(p => p.Updatedate) : query.OrderByDescending(p => p.Updatedate); break; } } if (limitOffset.HasValue) { query = query.Skip(limitOffset.Value).Take(limitRowCount.Value); } return(query.ToList()); }
static void ReadConfig() { var fileStream = System.IO.File.Open(System.IO.Directory.GetCurrentDirectory() + "/server.txt", System.IO.FileMode.Open); StreamReader reader = new StreamReader(fileStream); while (!reader.EndOfStream) { var line = reader.ReadLine(); if (line.StartsWith("#") || string.IsNullOrEmpty(line)) continue; line = line.TrimStart(' ').TrimEnd(' '); if (line.StartsWith("sh")) { string cmd = line.Substring(3); command.Add(cmd); } else { var datas = line.Split(' '); if (datas.Length < 3) continue; ClientData cdata = new ClientData(); cdata.ip = datas[0]; cdata.username = datas[1]; cdata.password = datas[2]; clients.Add(cdata); } } }
/* ** Decode a pointer to an sqlite3 object. */ //extern int getDbPointer(Tcl_Interp *interp, string zA, sqlite3 **ppDb); /* ** Register the echo virtual table module. */ static int register_tclvar_module( ClientData clientData,/* Pointer to sqlite3_enable_XXX function */ Tcl_Interp interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj[] objv /* Command arguments */ ){ sqlite3 db=null; if( objc!=2 ){ TCL.Tcl_WrongNumArgs(interp, 1, objv, "DB"); return TCL.TCL_ERROR; } if( getDbPointer(interp, TCL.Tcl_GetString(objv[1]), out db) !=0) return TCL.TCL_ERROR; #if !SQLITE_OMIT_VIRTUALTABLE sqlite3_create_module(db, "tclvar", tclvarModule, interp); #endif return TCL.TCL_OK; }
static void RunCommand(ClientData client) { IClient cli = new Client2(client.ip, client.username, client.password); cli.Connect(); Console.WriteLine(); Console.WriteLine(client.ip + " Running..."); foreach (var cmd in command) { cli.WaitForIdle(); cli.SendCommand(cmd); } cli.WaitForIdle(); cli.Disconnect(); cli = null; Console.WriteLine(); Console.WriteLine(client.ip + " Finished..."); }
static void RecvClient() { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.Bind(new IPEndPoint(IPAddress.Any, 10001)); EndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 10001); socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); byte[] buffer = new byte[1024]; while (true) { var count = socket.ReceiveFrom(buffer, ref iep1); string msg = Encoding.ASCII.GetString(buffer, 0, count); if (msg == "MultySSH") { ClientData cd = new ClientData(); cd.ip = ((IPEndPoint)iep1).Address.ToString(); cd.username = "******"; cd.password = "******"; var c = (from j in clients where j.ip == cd.ip select j).FirstOrDefault(); if(c== null) { clients.Add(cd); } } } }
void DispatchEvent(ClientData client, float priority, EndpointId endpointId, BitStream stream, bool reliable) { if (reliable) { m_callback.SendEvent(stream, true, endpointId); } else { client.EventQueue.Enqueue(stream, priority, endpointId); } }
// GET: Client public ActionResult Index() { var client = new ClientData(); return(View(client.GetList())); }
protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId, uint timestamp) { base.ServerRead(stream, clientId, timestamp); bool clientHasCharacter = stream.ReadBool(); if (clientHasCharacter) { MyEntity support; bool hasSupport = stream.ReadBool(); Vector3D supportPosition = Vector3D.Zero; if (m_character != null) { var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup <MyCharacterPhysicsStateGroup>(); if (physGroup != null) { m_support = MySupportHelper.FindSupportForCharacterAABB(m_character); physGroup.SetSupport(MySupportHelper.FindPhysics(m_support)); } } if (hasSupport) { long supportId = stream.ReadInt64(); bool apply = MyEntities.TryGetEntityById(supportId, out support); supportPosition = stream.ReadVector3D(); } if (m_additionalServerClientData == null) { m_additionalServerClientData = new Dictionary <ulong, ClientData>(); } m_additionalServerClientData[clientId] = new ClientData() { HasSupport = hasSupport, SupportPosition = supportPosition }; Vector3 move = new Vector3(); move.X = stream.ReadHalf(); move.Y = stream.ReadHalf(); move.Z = stream.ReadHalf(); Vector2 rotate = new Vector2(); rotate.X = stream.ReadFloat(); rotate.Y = stream.ReadFloat(); float roll = stream.ReadFloat(); MyCharacterMovementEnum MovementState = (MyCharacterMovementEnum)stream.ReadUInt16(); MyCharacterMovementFlags MovementFlag = (MyCharacterMovementFlags)stream.ReadUInt16(); bool Jetpack = stream.ReadBool(); bool Dampeners = stream.ReadBool(); bool Lights = stream.ReadBool(); // TODO: Remove bool Ironsight = stream.ReadBool(); bool Broadcast = stream.ReadBool(); // TODO: Remove bool TargetFromCamera = stream.ReadBool(); float headXAngle = stream.ReadFloat(); float headYAngle = stream.ReadFloat(); if (m_character == null) { return; } if (m_character.IsUsing != null) { return; } var jetpack = m_character.JetpackComp; if (jetpack != null) { if (Jetpack != jetpack.TurnedOn) { jetpack.TurnOnJetpack(Jetpack, true); } if (Dampeners != jetpack.DampenersTurnedOn) { jetpack.EnableDampeners(Dampeners, false); } } if (Lights != m_character.LightEnabled) { m_character.EnableLights(Lights); } if (m_character.RadioBroadcaster != null && Broadcast != m_character.RadioBroadcaster.Enabled) { m_character.EnableBroadcasting(Broadcast); } m_character.TargetFromCamera = TargetFromCamera; // Set client movement state directly and don't perform other operations // that may have side-effects to let server side Character.UpdateAfterSimulation() // perform exactly same operations as on client m_character.MovementFlags = MovementFlag; if (m_character.IsDead == false) { m_character.SetCurrentMovementState(MovementState); } m_character.HeadLocalXAngle = headXAngle; m_character.HeadLocalYAngle = headYAngle; if (m_commandsApplied == null) { m_commandsApplied = new Dictionary <ulong, bool>(); } if (Vector3.IsZero(move, 0.01f) == false || Vector2.IsZero(ref rotate, 0.01f) == false || Math.Abs(roll - 0.0) > 0.01f) { m_commandsApplied[clientId] = true; } m_character.CacheMove(ref move, ref rotate, ref roll); } }
/// <summary> /// Client constructor. /// </summary> /// <param name="clientData">Instance of ClientData object with filled data.</param> public Client(ClientData clientData) { _clientData = clientData; }
public void Insert(Client obj) { ClientData data = new ClientData(); data.Insert(obj); }
private void OnDestroy() { ClientData.Clear(); }
public void SetData(AwardPB pb) { Debug.Log(pb.ResourceId + " " + pb.Num + " " + pb.Resource); //transform.Find("ItemImg").GetComponent<Image>(); //transform.Find("ItemNumTxt").GetComponent<Text>().text="X " + awardPB.Num; string path = ""; string name = ""; if (pb.Resource == ResourcePB.Item) { name = GlobalData.PropModel.GetPropBase(pb.ResourceId).Name; } else { name = ViewUtil.ResourceToString(pb.Resource); } if (pb.Resource == ResourcePB.Gold) { // vo.OwnedNum = (int)GlobalData.PlayerModel.PlayerVo.Gold; path = "Prop/particular/" + PropConst.GoldIconId; } else if (pb.Resource == ResourcePB.Gem) { path = "Prop/particular/" + PropConst.GemIconId; } else if (pb.Resource == ResourcePB.Power) { path = "Prop/particular/" + PropConst.PowerIconId; } else if (pb.Resource == ResourcePB.Card) { path = "Head/" + pb.ResourceId; CardPB cpb = GlobalData.CardModel.GetCardBase(pb.ResourceId); name = CardVo.SpliceCardName(cpb.CardName, cpb.Player); } else if (pb.Resource == ResourcePB.Memories) { path = "Prop/particular/123456789"; } else { path = "Prop/" + pb.ResourceId; } _propImage = transform.Find("PropImage").GetComponent <RawImage>(); _propNameTxt = transform.Find("PropNameTxt").GetComponent <Text>(); _ownTxt = transform.Find("ObtainText").GetComponent <Text>(); _propImage.texture = ResourceManager.Load <Texture>(path); _propNameTxt.text = name; _ownTxt.text = I18NManager.Get("GameMain_ActivityAwardItemObtainText", pb.Num); if (pb.Resource != ResourcePB.Card) { GameObject clickObj = transform.Find("ItemBg").gameObject; clickObj.transform.GetComponent <Image>().raycastTarget = true; PointerClickListener.Get(clickObj).onClick = //UIEventListener.Get(clickObj).onClick = go => { FlowText.ShowMessage(ClientData.GetItemDescById(pb.ResourceId, pb.Resource).ItemDesc); }; } // _propImage.SetNativeSize(); }
protected override void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId, uint timestamp) { base.ServerRead(stream, clientId, timestamp); bool clientHasCharacter = stream.ReadBool(); if (clientHasCharacter) { MyEntity support; bool hasSupport = stream.ReadBool(); Vector3D supportPosition = Vector3D.Zero; if (m_character != null) { var physGroup = MyExternalReplicable.FindByObject(m_character).FindStateGroup<MyCharacterPhysicsStateGroup>(); if (physGroup != null) { m_support = MySupportHelper.FindSupportForCharacterAABB(m_character); physGroup.SetSupport(MySupportHelper.FindPhysics(m_support)); } } if (hasSupport) { long supportId = stream.ReadInt64(); bool apply = MyEntities.TryGetEntityById(supportId, out support); supportPosition = stream.ReadVector3D(); } if(m_additionalServerClientData == null) { m_additionalServerClientData = new Dictionary<ulong, ClientData>(); } m_additionalServerClientData[clientId] = new ClientData() { HasSupport = hasSupport, SupportPosition = supportPosition }; Vector3 move = new Vector3(); move.X = stream.ReadHalf(); move.Y = stream.ReadHalf(); move.Z = stream.ReadHalf(); Vector2 rotate = new Vector2(); rotate.X = stream.ReadFloat(); rotate.Y = stream.ReadFloat(); float roll = stream.ReadFloat(); MyCharacterMovementEnum MovementState = (MyCharacterMovementEnum)stream.ReadUInt16(); MyCharacterMovementFlags MovementFlag = (MyCharacterMovementFlags)stream.ReadUInt16(); bool Jetpack = stream.ReadBool(); bool Dampeners = stream.ReadBool(); bool Lights = stream.ReadBool(); // TODO: Remove bool Ironsight = stream.ReadBool(); bool Broadcast = stream.ReadBool(); // TODO: Remove bool TargetFromCamera = stream.ReadBool(); float headXAngle = stream.ReadFloat(); float headYAngle = stream.ReadFloat(); if(m_character == null) { return; } if (m_character.IsUsing != null) { return; } var jetpack = m_character.JetpackComp; if (jetpack != null) { if (Jetpack != jetpack.TurnedOn) { jetpack.TurnOnJetpack(Jetpack, true); } if (Dampeners != jetpack.DampenersTurnedOn) { jetpack.EnableDampeners(Dampeners, false); } } if (Lights != m_character.LightEnabled) { m_character.EnableLights(Lights); } if (m_character.RadioBroadcaster != null && Broadcast != m_character.RadioBroadcaster.Enabled) { m_character.EnableBroadcasting(Broadcast); } m_character.TargetFromCamera = TargetFromCamera; // Set client movement state directly and don't perform other operations // that may have side-effects to let server side Character.UpdateAfterSimulation() // perform exactly same operations as on client m_character.MovementFlags = MovementFlag; if (m_character.IsDead == false) { m_character.SetCurrentMovementState(MovementState); } m_character.HeadLocalXAngle = headXAngle; m_character.HeadLocalYAngle = headYAngle; if (m_commandsApplied == null) { m_commandsApplied = new Dictionary<ulong, bool>(); } if (Vector3.IsZero(move, 0.01f) == false || Vector2.IsZero(ref rotate, 0.01f) == false || Math.Abs(roll - 0.0) > 0.01f) { m_commandsApplied[clientId] = true; } m_character.CacheMove(ref move, ref rotate, ref roll); } }
public ClientDataFront(string token) { clientData = new ClientData(token); ResultLinks = new List <string>(); ResultElements = new List <string>(); }
public bool LogIn(SslStream sslStream, BinaryReader binaryReader, BinaryWriter binaryWriter, out ClientData clientData, out CoreClientInformation coreClientInformation, out bool isNewClient) { clientData = null; coreClientInformation = null; isNewClient = false; Logger.Debug("Send key request"); binaryWriter.Write((byte)AuthentificationFeedback.GetKey); var keys = new KeyDatabase(); var index = Random.Next(keys.Length); var key = keys.GetKey(index, "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh"); binaryWriter.Write(index); var result = binaryReader.ReadString(); if (key != result) { binaryWriter.Write((byte)AuthentificationFeedback.InvalidKey); Logger.Info("Invalid key - denied"); return(false); } Logger.Debug("Valid key. Get hardware id"); binaryWriter.Write((byte)AuthentificationFeedback.GetHardwareId); var hardwareId = binaryReader.ReadString(); if (hardwareId.Length > 256) { Logger.Info("Client rejected because the hardware id was too long. Length: {0}, MaxLength: 256", hardwareId.Length); return(false); } Logger.Debug("Hardware id received: {0}", hardwareId); Logger.Debug("Get client from database..."); var knowClient = _databaseManager.GetClient(hardwareId, out clientData); string clientTag = null; Logger.Debug(knowClient ? "Client was already registered" : "Seems like a new client"); if (knowClient) { Logger.Debug("Client accepted"); binaryWriter.Write((byte)AuthentificationFeedback.Accepted); } else { Logger.Debug("Get client tag"); binaryWriter.Write((byte)AuthentificationFeedback.GetClientTag); clientTag = binaryReader.ReadString(); if (clientTag.Length > 256) { Logger.Info("Client rejected because the client tag was too long. Length: {0}, MaxLength: 256", clientTag.Length); return(false); } Logger.Debug("Client tag received: {0}. Client accepted", clientTag); binaryWriter.Write((byte)AuthentificationFeedback.Accepted); } var types = new List <Type>(BuilderPropertyHelper.GetAllBuilderPropertyTypes()) { typeof(BasicComputerInformation) }; var serializer = new Serializer(types); Logger.Debug("Attempt to deserialize BasicComputerInformation"); var basicComputerInformation = (BasicComputerInformation)serializer.Deserialize(sslStream); Logger.Debug("BasicComputerInformation received, processing..."); coreClientInformation = new CoreClientInformation { UserName = basicComputerInformation.UserName, OSName = basicComputerInformation.OperatingSystemName, OSType = basicComputerInformation.OperatingSystemType, Language = basicComputerInformation.Language, IsAdministrator = basicComputerInformation.IsAdministrator, IsServiceRunning = basicComputerInformation.IsServiceRunning, Plugins = basicComputerInformation.Plugins, LoadablePlugins = basicComputerInformation.LoadablePlugins, ClientConfig = basicComputerInformation.ClientConfig, ClientVersion = basicComputerInformation.ClientVersion, ClientPath = basicComputerInformation.ClientPath, ApiVersion = basicComputerInformation.ApiVersion, FrameworkVersion = basicComputerInformation.FrameworkVersion }; if (basicComputerInformation.MacAddress?.Length == 6) { coreClientInformation.MacAddress = basicComputerInformation.MacAddress; } Logger.Trace("Client Information:\r\n{0}", coreClientInformation); if (coreClientInformation.OSName.Length > 256) { Logger.Info("Client rejected because the OSName was too long. Length: {0}, MaxLength: 256", coreClientInformation.OSName.Length); return(false); } if (coreClientInformation.UserName.Length > 256) { Logger.Info("Client rejected because the UserName was too long. Length: {0}, MaxLength: 256", coreClientInformation.UserName.Length); return(false); } if (coreClientInformation.Language.Length > 32) { Logger.Info("Client rejected because the Language was too long. Length: {0}, MaxLength: 256", coreClientInformation.Language.Length); return(false); } Logger.Debug("Seems like the information is OK"); if (knowClient) { Logger.Debug("Because the client was already registered, updating database entry"); _databaseManager.RefreshClient(clientData.Id, coreClientInformation.UserName, coreClientInformation.OSName, (int)coreClientInformation.OSType, coreClientInformation.Language, coreClientInformation.MacAddress); clientData.UserName = coreClientInformation.UserName; clientData.OSName = coreClientInformation.OSName; clientData.OSType = coreClientInformation.OSType; clientData.Language = coreClientInformation.Language; clientData.MacAddress = coreClientInformation.MacAddress; } else { Logger.Info("Register client..."); Logger.Debug("Create database entry"); var id = _databaseManager.AddClient(coreClientInformation.UserName, hardwareId, coreClientInformation.OSName, (int)coreClientInformation.OSType, coreClientInformation.Language, clientTag, coreClientInformation.MacAddress); if (id == -1) { Logger.Error("The generated id of the new client is -1"); return(false); } clientData = new ClientData { Id = id, Language = coreClientInformation.Language, HardwareId = hardwareId, LastSeen = DateTime.UtcNow, UserName = coreClientInformation.UserName, OSType = coreClientInformation.OSType, OSName = coreClientInformation.OSName, Group = clientTag, MacAddress = coreClientInformation.MacAddress }; } Logger.Debug("Client authentication successful"); isNewClient = !knowClient; return(true); }
private void SetProgress(ActivityTemplateModel model) { //找出进度条开始的位置 int showLen = _tabBarTran.childCount; int totalLen = (model.activeHolidayAwardRules != null) ? model.activeHolidayAwardRules.Count : 0; int myCount = model.GetUserActivityHolidayInfo().DrawCount; int startIndex = 0; int index = 0; int startValue = 0; for (int i = 0; i < totalLen; ++i) { int weight = model.activeHolidayAwardRules[i].Weight; if (myCount >= weight) { bool isGet = model.GetUserActivityHolidayInfo().ActiveProgress.Contains(weight); if (!isGet) { break; } index = i + 1; if (index > totalLen - 1) { break; } if (index % showLen == 0) { startIndex = index; startValue = weight; } } } index = startIndex + showLen; if (index >= totalLen) { index = totalLen - 1; } float progress = 0f; int lastValue = startValue; for (int i = startIndex; i <= index; ++i) { int weight = model.activeHolidayAwardRules[i].Weight; if (myCount >= weight) { if (i == totalLen - 1) { progress += ((float)(myCount - lastValue) / (weight - lastValue)) * (1f / 6f); } else { progress += 1f / 6f; } lastValue = weight; //Debug.LogWarning(">= weight:" + weight + " progress:"+progress); } else { progress += ((float)(myCount - lastValue) / (weight - lastValue)) * (1f / 6f); //Debug.LogWarning("< weight:" + weight + " lastValue:" + lastValue + " progress:"+progress); break; } } if (progress > 1) { progress = 1f; } if (progress < 0) { progress = 0f; } //Debug.LogWarning("myCount:"+myCount + " startValue:"+startValue + " endValue:"+endValue); //Debug.LogWarning("progress:" + progress + " index:"+index); _progressBar.sizeDelta = new Vector2(progress * 972.92f, _progressBar.sizeDelta.y); //Debug.LogWarning("startIndex:"+startIndex); for (int i = 0; i < _tabBarTran.childCount; i++) { int weight = model.Weight(startIndex + i); //int weight = model.Weight(i); var frameBg = _tabBarTran.GetChild(i).Find("FrameBg"); var icon = frameBg.GetRawImage("Icon"); var redDot = frameBg.Find("RedDot"); var num = _tabBarTran.GetChild(i).GetText("WeightTxt"); num.text = weight.ToString(); var mask = _tabBarTran.GetChild(i).Find("Mask"); var iconNum = frameBg.GetText("IconNum"); var rewards = model.GetActiveAward(weight); PointerClickListener.Get(icon.gameObject).onClick = null; bool isGift = rewards.Count > 1; if (!isGift) { RewardVo vo = new RewardVo(rewards[0]); icon.texture = ResourceManager.Load <Texture>(vo.IconPath); icon.gameObject.Show(); icon.transform.GetChild(0).gameObject.SetActive(vo.Resource == ResourcePB.Puzzle); iconNum.text = vo.Num.ToString(); } else { string path = "Prop/GiftPack/tongyong2"; icon.texture = ResourceManager.Load <Texture>(path); icon.gameObject.Show(); iconNum.transform.gameObject.Hide(); icon.transform.GetChild(0).gameObject.Hide(); } //是否初始化 if (model.GetUserActivityHolidayInfo().ActiveProgress == null) { redDot.gameObject.Hide(); mask.gameObject.Hide(); PointerClickListener.Get(icon.gameObject).onClick = go => { if (!isGift) { FlowText.ShowMessage(ClientData.GetItemDescById(rewards[0].ResourceId, rewards[0].Resource).ItemDesc); } else { //打开奖励预览窗口 var window = PopupManager.ShowWindow <CommonAwardWindow>("GameMain/Prefabs/AwardWindow/CommonAwardWindow"); window.SetData(rewards.ToList(), true, ModuleConfig.MODULE_ACTIVITYTEMPLATE); } }; } else { //是否领取过 isGet为true领取过,false未领取 var isGet = model.GetUserActivityHolidayInfo().ActiveProgress.Contains(weight); //是否可以领取 isMayGet为true可以领,false未领取 var isMayGet = model.GetUserActivityHolidayInfo().DrawCount >= weight; if (isMayGet && !isGet) //可以领,没领过 { frameBg.gameObject.Show(); mask.gameObject.Hide(); redDot.gameObject.Show(); PointerClickListener.Get(icon.gameObject).onClick = go => { SendMessage(new Message(MessageConst.CMD_ACTIVITYTEMPLATE1_GET_ACTIVE_AWARD, Message.MessageReciverType.CONTROLLER, weight)); }; } else if (isMayGet && isGet) //可以领,领过了 { frameBg.gameObject.Hide(); mask.gameObject.Show(); } else if (!isMayGet) //不可以领 { frameBg.gameObject.Show(); redDot.gameObject.Hide(); mask.gameObject.Hide(); PointerClickListener.Get(icon.gameObject).onClick = go => { if (!isGift) { FlowText.ShowMessage(ClientData.GetItemDescById(rewards[0].ResourceId, rewards[0].Resource).ItemDesc); } else { //打开奖励预览窗口 var window = PopupManager.ShowWindow <CommonAwardWindow>("GameMain/Prefabs/AwardWindow/CommonAwardWindow"); window.SetData(rewards.ToList(), true, ModuleConfig.MODULE_ACTIVITYTEMPLATE); } }; } } } }
public void DoWork(uint clientPort, ref string solution) { RestClient webServer; shouldStop = false; //Connect to web server ClientListData updatedClients = null; webServer = new RestClient("https://localhost:44370/"); while (!shouldStop) { //Attempt to grab/update client list from web server RestRequest req = new RestRequest("api/clients"); IRestResponse resp = webServer.Get(req); if (resp.IsSuccessful) { //Update client list. updatedClients = JsonConvert.DeserializeObject <ClientListData>(resp.Content); clients = new List <ClientData>(updatedClients.clients); //Look for a job to do. IEnumerator <ClientData> enumerator = clients.GetEnumerator(); enumerator.MoveNext(); ClientData curr = enumerator.Current; bool keepSearching = true; while (enumerator.Current != null && keepSearching) { //Ignore the current client if it is the server's owning client if (curr.port != clientPort) { try { //Connect to that client's server NetTcpBinding tcp = new NetTcpBinding(); string URL = String.Concat("net.tcp://localhost:", curr.port.ToString(), "/ClientServer"); ChannelFactory <JobServerInterface> jobServerFactory; jobServerFactory = new ChannelFactory <JobServerInterface>(tcp, URL); JobServerInterface clientServer = jobServerFactory.CreateChannel(); //Check list of available jobs List <Job> jobs = clientServer.GetJobs(); //Do job if found, then stop searching. Job foundJob = jobs.Find(x => x.solution == null); if (foundJob != null) { //do job clientServer.SubmitSolution(foundJob.localID, "testSolution"); keepSearching = false; } /*DEBUG: Attempt to do all jobs. * for(int ii=0; ii < jobs.Count; ii++) * { * Job foundJob = jobs.ElementAt(ii); * * //Do job if found, then stop searching. * if (foundJob != null && foundJob.solution == null) * { * //do job * clientServer.SubmitSolution(foundJob.localID, "testSolution"); * * keepSearching = false; * } * } */ } catch (EndpointNotFoundException e) { //Server may have been closed unexpectedly, skip this client. } //end try catch } //end if //Progress client enumerator enumerator.MoveNext(); curr = enumerator.Current; } //end while } else //If some problem occurs... { //Don't update list. if (clients == null) //List will be empty on first request. If an error occurred, close thread and log error. { shouldStop = true; Console.WriteLine("ERROR: Clients list could not be retrieved after connecting to the web server."); } } //Wait half a second before updating the list again and looking for a job to do. Thread.Sleep(500); }//Loop runs until Stop() is called by another thread }
private static void ImportJson(IDataStoreContext ctx, ClientData data, ClientJson json) { data.Name = json.Name; data.WorkspaceId = GetLocalId <WorkspaceData> (ctx, json.WorkspaceId); ImportCommonJson(data, json); }
public void SetDefaultClient(ClientData client) { _settings.DefaultsStore.SetDefaultClientId(client?.Id); }
public ClientData Import(IDataStoreContext ctx, ClientJson json, Guid?localIdHint = null, ClientData mergeBase = null) { var log = ServiceContainer.Resolve <Logger> (); var data = GetByRemoteId <ClientData> (ctx, json.Id.Value, localIdHint); var merger = mergeBase != null ? new ClientMerger(mergeBase) : null; if (merger != null && data != null) { merger.Add(new ClientData(data)); } if (json.DeletedAt.HasValue) { if (data != null) { log.Info(Tag, "Deleting local data for {0}.", data.ToIdString()); ctx.Delete(data); data = null; } } else if (merger != null || ShouldOverwrite(data, json)) { data = data ?? new ClientData(); ImportJson(ctx, data, json); if (merger != null) { merger.Add(data); data = merger.Result; } if (merger != null) { log.Info(Tag, "Importing {0}, merging with local data.", data.ToIdString()); } else { log.Info(Tag, "Importing {0}, replacing local data.", data.ToIdString()); } data = ctx.Put(data); } else { log.Info(Tag, "Skipping import of {0}.", json.ToIdString()); } return(data); }
private void clientGetSnapshot(String encodedData) { int parseIndex = 0; // Extract the signature int signature = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; // If the received snapshot is older (or even equal) to the last received one, ignore the rest if (signature <= lastSnapshotSignature) { return; } Snapshot snapshot = new Snapshot(); snapshot.signature = signature; // Initialize the player data and bot data arrays // Extract player data count int clientCount = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; // Then the player data itself for (int index = 0; index < clientCount; index++) { ClientData clientData = new ClientData(); clientData.id = encodedData.Split(";")[parseIndex]; parseIndex++; clientData.position.x = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.position.y = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.rotation = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.primaryWepaon = bool.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.secondaryWepaon = bool.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.health = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.primaryWeaponIndex = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.secondaryWeaponIndex = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; snapshot.playerData.Add(clientData.id, clientData); } // Extract bot data count clientCount = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; // Then the bot data for (int index = 0; index < clientCount; index++) { ClientData clientData = new ClientData(); clientData.id = encodedData.Split(";")[parseIndex]; parseIndex++; clientData.position.x = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.position.y = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.rotation = float.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.primaryWepaon = bool.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.secondaryWepaon = bool.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.health = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.primaryWeaponIndex = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; clientData.secondaryWeaponIndex = int.Parse(encodedData.Split(";")[parseIndex]); parseIndex++; snapshot.botData.Add(clientData.id, clientData); } // Update the "last_snapshot" lastSnapshotSignature = signature; // Emit the signal indicating that there is a new snapshot do be applied EmitSignal(nameof(SnapshotReceivedSignal), snapshot); }
public static void saveFile(int type, object obj) { IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; switch (type) { case (int)UMSApi.DataType.CLIENTDATA: // client data List <ClientData> list_clientdata = new List <ClientData>(); ClientData c = (ClientData)obj; if (settings.Contains("clientdata")) { list_clientdata = (List <ClientData>)settings["clientdata"]; list_clientdata.Add(c); settings["clientdata"] = list_clientdata; } else { list_clientdata.Add(c); settings.Add("clientdata", list_clientdata); } settings.Save(); // DebugTool.Log("client data list size:" + list_clientdata.Count); break; case (int)UMSApi.DataType.EVENTDATA: //event data List <Event> list_event = new List <Event>(); Event e = (Event)obj; if (settings.Contains("eventdata")) { list_event = (List <Event>)settings["eventdata"]; list_event.Add(e); settings["eventdata"] = list_event; } else { list_event.Add(e); settings.Add("eventdata", list_event); } settings.Save(); DebugTool.Log("event list size:" + list_event.Count); break; case (int)UMSApi.DataType.TAGDATA: //tag data List <Tag> list_tag = new List <Tag>(); Tag tag = (Tag)obj; if (settings.Contains("tagdata")) { list_tag = (List <Tag>)settings["tagdata"]; list_tag.Add(tag); settings["tagdata"] = list_tag; } else { list_tag.Add(tag); settings.Add("tagdata", list_tag); } settings.Save(); DebugTool.Log("tag list size:" + list_tag.Count); break; case (int)UMSApi.DataType.ERRORDATA: //error data break; case (int)UMSApi.DataType.PAGEINFODATA: //page info data PageInfo pageinfo = (PageInfo)obj; List <PageInfo> list_pageinfo = new List <PageInfo>(); if (settings.Contains("pageinfo")) { list_pageinfo = (List <PageInfo>)settings["pageinfo"]; list_pageinfo.Add(pageinfo); settings["pageinfo"] = list_pageinfo; } else { list_pageinfo.Add(pageinfo); settings.Add("pageinfo", list_pageinfo); } settings.Save(); DebugTool.Log("pageinfo list size:" + list_pageinfo.Count); break; default: break; } if (settings.Contains("hasDateToSend")) { settings["hasDateToSend"] = "1"; } else { settings.Add("hasDateToSend", "1"); } }
public void HistoryFileIntergrityTest() { string testFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "history.test"); if (File.Exists(testFile)) { File.Delete(testFile); } var inv1 = new ClientData { ClientId = 10, Uid = "Uid1", Name = "Invoker1" }; var inv2 = new ClientData { ClientId = 20, Uid = "Uid2", Name = "Invoker2" }; var ar1 = new AudioResource("asdf", "sc_ar1", "soundcloud"); var ar2 = new AudioResource("./File.mp3", "me_ar2", "media"); var ar3 = new AudioResource("kitty", "tw_ar3", "twitch"); var data1 = new HistorySaveData(ar1, inv1.Uid); var data2 = new HistorySaveData(ar2, inv2.Uid); var data3 = new HistorySaveData(ar3, "Uid3"); var confHistory = ConfigTable.CreateRoot <ConfHistory>(); confHistory.FillDeletedIds.Value = false; var confDb = ConfigTable.CreateRoot <ConfDb>(); confDb.Path.Value = testFile; DbStore db; HistoryManager hf; void CreateDbStore() { db = new DbStore(confDb); hf = new HistoryManager(confHistory) { Database = db }; hf.Initialize(); } CreateDbStore(); hf.LogAudioResource(data1); var lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); var lastEntry = lastXEntries.First(); Assert.AreEqual(ar1, lastEntry.AudioResource); db.Dispose(); CreateDbStore(); lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); lastEntry = lastXEntries.First(); Assert.AreEqual(ar1, lastEntry.AudioResource); hf.LogAudioResource(data1); hf.LogAudioResource(data2); lastXEntries = hf.GetLastXEntrys(1); Assert.True(lastXEntries.Any()); lastEntry = lastXEntries.First(); Assert.AreEqual(ar2, lastEntry.AudioResource); db.Dispose(); // store and order check CreateDbStore(); var lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar2, lastXEntriesArray[0].AudioResource); Assert.AreEqual(ar1, lastXEntriesArray[1].AudioResource); var ale1 = hf.FindEntryByResource(ar1); hf.RenameEntry(ale1, "sc_ar1X"); hf.LogAudioResource(new HistorySaveData(ale1.AudioResource, "Uid4")); db.Dispose(); // check entry renaming CreateDbStore(); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar1, lastXEntriesArray[0].AudioResource); Assert.AreEqual(ar2, lastXEntriesArray[1].AudioResource); var ale2 = hf.FindEntryByResource(ar2); hf.RenameEntry(ale2, "me_ar2_loong1"); hf.LogAudioResource(new HistorySaveData(ale2.AudioResource, "Uid4")); ale1 = hf.FindEntryByResource(ar1); hf.RenameEntry(ale1, "sc_ar1X_loong1"); hf.LogAudioResource(new HistorySaveData(ale1.AudioResource, "Uid4")); hf.RenameEntry(ale2, "me_ar2_exxxxxtra_loong1"); hf.LogAudioResource(new HistorySaveData(ale2.AudioResource, "Uid4")); db.Dispose(); // recheck order CreateDbStore(); lastXEntriesArray = hf.GetLastXEntrys(2).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); Assert.AreEqual(ar2, lastXEntriesArray[0].AudioResource); Assert.AreEqual(ar1, lastXEntriesArray[1].AudioResource); db.Dispose(); // delete entry 1 CreateDbStore(); hf.RemoveEntry(hf.FindEntryByResource(ar1)); lastXEntriesArray = hf.GetLastXEntrys(3).ToArray(); Assert.AreEqual(1, lastXEntriesArray.Length); // .. store new entry to check correct stream position writes hf.LogAudioResource(data3); lastXEntriesArray = hf.GetLastXEntrys(3).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); db.Dispose(); // delete entry 2 CreateDbStore(); // .. check integrity from previous store lastXEntriesArray = hf.GetLastXEntrys(3).ToArray(); Assert.AreEqual(2, lastXEntriesArray.Length); // .. delete and recheck hf.RemoveEntry(hf.FindEntryByResource(ar2)); lastXEntriesArray = hf.GetLastXEntrys(3).ToArray(); Assert.AreEqual(1, lastXEntriesArray.Length); Assert.AreEqual(ar3, lastXEntriesArray[0].AudioResource); db.Dispose(); File.Delete(testFile); }
protected virtual void ServerRead(VRage.Library.Collections.BitStream stream, ulong clientId,uint timestamp) { m_clientUpdateFlag[clientId] = true; ClientData data = new ClientData(); data.TimeStamp = timestamp; data.Transform = new MyTransformD(); data.Transform.Rotation = stream.ReadQuaternionNorm(); data.Transform.Position = stream.ReadVector3D(); m_serverClientData[clientId] = data; }
public int UpdateInput() { if (Global.IsConnect()) { //游戏是否开始 if (Global.GetMapManager() != null && Global.GetMapManager().situation <= 1) { if (inputManager.IsComplete()) { //发送到服务端 { var dat = new ClientData(); if (Global.IsCameraFree) { dat.CreateInput(inputManager.GetTime(), Global.GetInput().GetKeyBoolNull()); } else { dat.CreateInput(inputManager.GetTime(), Global.GetInput().GetKeyBool()); } Global.GetClientC().AddData(dat); } var rep = Global.GetReplayManager(); var sw = rep.GetSw(); if (inputManager.IsBegin()) { var player = Global.GetPlayer(); string path = GlobalB.GetRootPath() + @"\Setting\PlayerData\" + (player.GetQQ() + "_" + player.GetExID() + @"\Replay"); if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } var time = DateTime.Now; int[] times = new int[6] { time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second }; string timeStr = ""; for (int i = 0; i < 6; i++) { if (i == 3) { timeStr = timeStr + "_"; } if (times[i] < 10) { timeStr = timeStr + "0"; } timeStr = timeStr + times[i]; } path = path + "\\" + timeStr + ".rep"; rep.Start(path); sw = rep.GetSw(); sw.WriteLine("" + GetPlayerNum()); // bool[] dat = new bool[6]; for (int i = 0; i < 6; i++) { dat[i] = (players[i].player != null); } inputManager.SetPlayer(dat); } int index = 0; for (int i = 0; i < 6; i++) { if (inputManager.IsIn(i)) { var player = players[i].player; if (player != null) { var inp = inputManager.GetInput(i); { //player.input.UpdateKey(inp); //???? //创建的player有误? Global.GetMapManager().pla.list[index].player.input.UpdateKey(inp); index++; } for (int j = 0; j < 9; j++) { if (inp[j]) { sw.Write('1'); } else { sw.Write('0'); } } sw.Write(' '); } } } sw.WriteLine(); inputManager.Update(); } else { return(1); } } } else { //本地更新 if (Global.IsCameraFree) { Global.GetPlayer().input.UpdateKey(Global.GetInput().GetKeyBoolNull()); } else { Global.GetPlayer().input.UpdateKey(Global.GetInput().GetKeyBool()); } } return(0); }
/***************************************************************************** ** Everything below is interface for testing this module. */ #if SQLITE_TEST //#include <tcl.h> /* ** Routines to encode and decode pointers */ //extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb); //extern void *sqlite3TestTextToPtr(const char*); //extern int sqlite3TestMakePointerStr(Tcl_Interp*, char *zPtr, void*); //extern const char *sqlite3TestErrorName(int); /* ** sqlite3_intarray_create DB NAME ** ** Invoke the sqlite3_intarray_create interface. A string that becomes ** the first parameter to sqlite3_intarray_bind. */ static int test_intarray_create( ClientData clientData, /* Not used */ Tcl_Interp interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj[] objv /* Command arguments */ ) { sqlite3 db; string zName; sqlite3_intarray pArray; int rc = SQLITE_OK; StringBuilder zPtr = new StringBuilder( 100 ); if ( objc != 3 ) { TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB" ); return TCL.TCL_ERROR; } if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 ) return TCL.TCL_ERROR; zName = TCL.Tcl_GetString( objv[2] ); #if !SQLITE_OMIT_VIRTUALTABLE rc = sqlite3_intarray_create( db, zName, out pArray ); #endif if ( rc != SQLITE_OK ) { Debug.Assert( pArray == null ); TCL.Tcl_AppendResult( interp, sqlite3TestErrorName( rc ), null ); return TCL.TCL_ERROR; } sqlite3TestMakePointerStr( interp, zPtr, pArray ); TCL.Tcl_AppendResult( interp, zPtr, null ); return TCL.TCL_OK; }
public void SetData(FirstRechargeVO vO) { _icon.texture = ResourceManager.Load <Texture>(vO.RewardVo.IconPath, ModuleConfig.MODULE_ACTIVITY); _icon.GetComponent <RectTransform>().sizeDelta = new Vector2(200, 200); _num.text = vO.RewardVo.Num.ToString(); if (vO.RewardVo.Resource != ResourcePB.Card) { PointerClickListener.Get(gameObject).onClick = go => { FlowText.ShowMessage(ClientData.GetItemDescById(vO.RewardVo.Id, vO.RewardVo.Resource).ItemDesc); }; } }
public PlayData(BotSession session, ClientData invoker, string message, bool enqueue) { Session = session; Invoker = invoker; Message = message; Enqueue = enqueue; Resource = null; Volume = -1; }
private void Start() { ClientData.LoadItemDescData(null); ClientData.LoadSpecialItemDescData(null); }
private void AddClientReplicable(IMyReplicable replicable, ClientData clientData) { // Add replicable clientData.Replicables.Add(replicable, new MyReplicableClientData()); // Add state groups foreach (var group in m_replicableGroups[replicable]) { var netId = GetNetworkIdByObject(group); clientData.StateGroups.Add(group, new MyStateDataEntry(replicable, netId, group)); group.CreateClientData(clientData.State); } }
static int testvfs_obj_cmd( ClientData cd, Tcl_Interp interp, int objc, Tcl_Obj[] objv ){ Debugger.Break();//TODO // Testvfs p = (Testvfs)cd; // TestvfsSubcmd[] aSubcmd = new TestvfsSubcmd[] { // new TestvfsSubcmd( "shm", DB_enum_CMD.CMD_SHM ), // new TestvfsSubcmd( "delete", DB_enum_CMD.CMD_DELETE ), // new TestvfsSubcmd( "filter", DB_enum_CMD.CMD_FILTER ), // new TestvfsSubcmd( "ioerr", DB_enum_CMD.CMD_IOERR ), // new TestvfsSubcmd( "fullerr", DB_enum_CMD.CMD_FULLERR ), // new TestvfsSubcmd( "cantopenerr", DB_enum_CMD.CMD_CANTOPENERR ), // new TestvfsSubcmd( "script", DB_enum_CMD.CMD_SCRIPT ), // new TestvfsSubcmd( "devchar", DB_enum_CMD.CMD_DEVCHAR ), // new TestvfsSubcmd( "sectorsize", DB_enum_CMD.CMD_SECTORSIZE ), // new TestvfsSubcmd( 0, 0 ) // }; // int i=0; // if( objc<2 ){ // TCL.Tcl_WrongNumArgs( interp, 1, objv, "SUBCOMMAND ..." ); // return TCL.TCL_ERROR; // } // if ( TCL.Tcl_GetIndexFromObjStruct( // interp, objv[1], aSubcmd, aSubcmd.Length, "subcommand", 0, ref i) // ){ // return TCL.TCL_ERROR; // } // TCL.Tcl_ResetResult( interp ); // switch( aSubcmd[i].eCmd ){ // case DB_enum_CMD.CMD_SHM: { // Tcl_Obj pObj; // int i; // TestvfsBuffer pBuffer; // string zName; // if( objc!=3 && objc!=4 ){ // TCL.Tcl_WrongNumArgs( interp, 2, objv, "FILE ?VALUE?" ); // return TCL.TCL_ERROR; // } // zName = ckalloc(p.pParent.mxPathname); // p.pParent.xFullPathname( // p.pParent, TCL.Tcl_GetString(objv[2]), // p.pParent.mxPathname, zName // ); // for(pBuffer=p.pBuffer; pBuffer; pBuffer=pBuffer.pNext){ // if( 0==strcmp(pBuffer.zFile, zName) ) break; // } // ckfree(zName); // if( null==pBuffer ){ // TCL.Tcl_AppendResult( interp, "no such file: ", TCL.Tcl_GetString( objv[2] ), 0 ); // return TCL.TCL_ERROR; // } // if( objc==4 ){ // int n; // u8 *a = TCL.Tcl_GetByteArrayFromObj(objv[3], &n); // int pgsz = pBuffer.pgsz; // if( pgsz==0 ) pgsz = 65536; // for(i=0; ipgsz<n; i++){ // int nByte = pgsz; // tvfsAllocPage(pBuffer, i, pgsz); // if( n-ipgsz<pgsz ){ // nByte = n; // } // memcpy(pBuffer.aPage[i], &a[ipgsz], nByte); // } // } // pObj = TCL.Tcl_NewObj(); // for(i=0; pBuffer.aPage[i]!=null; i++){ // int pgsz = pBuffer.pgsz; // if( pgsz==0 ) pgsz = 65536; // TCL.Tcl_AppendObjToObj(pObj, TCL.Tcl_NewByteArrayObj(pBuffer.aPage[i], pgsz)); // } // TCL.Tcl_SetObjResult( interp, pObj ); // break; // } // case DB_enum_CMD.CMD_FILTER: { //VfsMethod[] vfsmethod = new VfsMethod[] { // new VfsMethod( "xShmOpen", TESTVFS_SHMOPEN_MASK ), // new VfsMethod( "xShmLock", TESTVFS_SHMLOCK_MASK ), // new VfsMethod( "xShmBarrier", TESTVFS_SHMBARRIER_MASK ), // new VfsMethod( "xShmUnmap", TESTVFS_SHMCLOSE_MASK ), // new VfsMethod( "xShmMap", TESTVFS_SHMMAP_MASK ), // new VfsMethod( "xSync", TESTVFS_SYNC_MASK ), // new VfsMethod( "xDelete", TESTVFS_DELETE_MASK ), // new VfsMethod( "xWrite", TESTVFS_WRITE_MASK ), // new VfsMethod( "xTruncate", TESTVFS_TRUNCATE_MASK ), // new VfsMethod( "xOpen", TESTVFS_OPEN_MASK ), // new VfsMethod( "xClose", TESTVFS_CLOSE_MASK ), // new VfsMethod( "xAccess", TESTVFS_ACCESS_MASK ), // new VfsMethod( "xFullPathname", TESTVFS_FULLPATHNAME_MASK ), //}; // Tcl_Obj[] apElem = null; // int nElem = 0; // int i; // int mask = 0; // if( objc!=3 ){ // TCL.Tcl_WrongNumArgs( interp, 2, objv, "LIST" ); // return TCL.TCL_ERROR; // } // if ( TCL.Tcl_ListObjGetElements( interp, objv[2], ref nElem, ref apElem ) ) // { // return TCL.TCL_ERROR; // } // TCL.Tcl_ResetResult( interp ); // for(i=0; i<nElem; i++){ // int iMethod; // string zElem = TCL.Tcl_GetString(apElem[i]); // for(iMethod=0; iMethod<ArraySize(vfsmethod); iMethod++){ // if( strcmp(zElem, vfsmethod[iMethod].zName)==0 ){ // mask |= vfsmethod[iMethod].mask; // break; // } // } // if( iMethod==ArraySize(vfsmethod) ){ // TCL.Tcl_AppendResult( interp, "unknown method: ", zElem, 0 ); // return TCL.TCL_ERROR; // } // } // p.mask = mask; // break; // } // case DB_enum_CMD.CMD_SCRIPT: { // if( objc==3 ){ // int nByte; // if( p.pScript !=null){ // TCL.Tcl_DecrRefCount( p.pScript ); // p.pScript = 0; // } // TCL.Tcl_GetStringFromObj( objv[2], &nByte ); // if( nByte>0 ){ // p.pScript = TCL.Tcl_DuplicateObj(objv[2]); // TCL.Tcl_IncrRefCount( p.pScript ); // } // }else if( objc!=2 ){ // TCL.Tcl_WrongNumArgs( interp, 2, objv, "?SCRIPT?" ); // return TCL.TCL_ERROR; // } // TCL.Tcl_ResetResult( interp ); // if( p.pScript !=null) if( p.pScript )TCL.Tcl_SetObjResult(interp, p.pScript); // break; // } // /* // ** TESTVFS ioerr ?IFAIL PERSIST? // ** // ** Where IFAIL is an integer and PERSIST is boolean. // */ // case DB_enum_CMD.CMD_CANTOPENERR: // case DB_enum_CMD.CMD_IOERR: // case DB_enum_CMD.CMD_FULLERR: { // TestFaultInject pTest; // int iRet; // switch( aSubcmd[i].eCmd ){ // case DB_enum_CMD.CMD_IOERR: pTest = p.ioerr_err; break; // case DB_enum_CMD.CMD_FULLERR: pTest = p.full_err; break; // case DB_enum_CMD.CMD_CANTOPENERR: pTest = p.cantopen_err; break; // default: Debug.Assert(false); // } // iRet = pTest.nFail; // pTest.nFail = 0; // pTest.eFault = 0; // pTest.iCnt = 0; // if( objc==4 ){ // int iCnt, iPersist; // if ( TCL.TCL_OK != TCL.Tcl_GetIntFromObj( interp, objv[2], &iCnt ) // || TCL.TCL_OK != TCL.Tcl_GetBooleanFromObj( interp, objv[3], &iPersist ) // ){ // return TCL.TCL_ERROR; // } // pTest.eFault = iPersist != 0 ? FAULT_INJECT_PERSISTENT : FAULT_INJECT_TRANSIENT; // pTest.iCnt = iCnt; // }else if( objc!=2 ){ // TCL.Tcl_WrongNumArgs( interp, 2, objv, "?CNT PERSIST?" ); // return TCL.TCL_ERROR; // } // TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( iRet ) ); // break; // } // case DB_enum_CMD.CMD_DELETE: { // TCL.Tcl_DeleteCommand( interp, TCL.Tcl_GetString( objv[0] ) ); // break; // } // case DB_enum_CMD.CMD_DEVCHAR: { //_aFlag[] aFlag = new _aFlag[] { // new _aFlag( "default", -1 ), // new _aFlag( "atomic", SQLITE_IOCAP_ATOMIC ), // new _aFlag( "atomic512", SQLITE_IOCAP_ATOMIC512 ), // new _aFlag( "atomic1k", SQLITE_IOCAP_ATOMIC1K ), // new _aFlag( "atomic2k", SQLITE_IOCAP_ATOMIC2K ), // new _aFlag( "atomic4k", SQLITE_IOCAP_ATOMIC4K ), // new _aFlag( "atomic8k", SQLITE_IOCAP_ATOMIC8K ), // new _aFlag( "atomic16k", SQLITE_IOCAP_ATOMIC16K ), // new _aFlag( "atomic32k", SQLITE_IOCAP_ATOMIC32K ), // new _aFlag( "atomic64k", SQLITE_IOCAP_ATOMIC64K ), // new _aFlag( "sequential", SQLITE_IOCAP_SEQUENTIAL ), // new _aFlag( "safe_append", SQLITE_IOCAP_SAFE_APPEND ), // new _aFlag( "undeletable_when_open", SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ), // new _aFlag( 0, 0 ) // }; // Tcl_Obj pRet; // int iFlag; // if( objc>3 ){ // Tcl_WrongNumArgs(interp, 2, objv, "?ATTR-LIST?"); // return TCL.TCL_ERROR; // } // if( objc==3 ){ // int j; // int iNew = 0; // Tcl_Obj[] flags = null; // int nFlags = 0; // if ( TCL.Tcl_ListObjGetElements( interp, objv[2], ref nFlags, ref flags ) ) // { // return TCL.TCL_ERROR; // } // for(j=0; j<nFlags; j++){ // int idx = 0; // if( Tcl_GetIndexFromObjStruct(interp, flags[j], aFlag, // aFlag.Length, "flag", 0, ref idx) // ){ // return TCL.TCL_ERROR; // } // if( aFlag[idx].iValue<0 && nFlags>1 ){ // TCL.Tcl_AppendResult( interp, "bad flags: ", TCL.Tcl_GetString( objv[2] ), 0 ); // return TCL.TCL_ERROR; // } // iNew |= aFlag[idx].iValue; // } // p.iDevchar = iNew; // } // pRet = TCL.Tcl_NewObj(); // for(iFlag=0; iFlag<aFlag.Length ; iFlag++)//sizeof(aFlag)/sizeof(aFlag[0]); iFlag++) // { // if( p.iDevchar & aFlag[iFlag].iValue ){ // TCL.Tcl_ListObjAppendElement( // interp, pRet, TCL.Tcl_NewStringObj(aFlag[iFlag].zName, -1) // ); // } // } // TCL.Tcl_SetObjResult( interp, pRet ); // break; // } // case DB_enum_CMD.CMD_SECTORSIZE: { // if( objc>3 ){ // TCL.Tcl_WrongNumArgs( interp, 2, objv, "?VALUE?" ); // return TCL.TCL_ERROR; // } // if( objc==3 ){ // int iNew = 0; // if( Tcl_GetIntFromObj(interp, objv[2], ref iNew) ){ // return TCL.TCL_ERROR; // } // p.iSectorsize = iNew; // } // TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( p.iSectorsize ) ); // break; // } // } return TCL.TCL_OK; }
/* ** Register the echo virtual table module. */ static int register_echo_module( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj[] objv /* Command arguments */ ) { sqlite3 db = null; ; ; EchoModule pMod; if ( objc != 2 ) { TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB" ); return TCL.TCL_ERROR; } if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 ) return TCL.TCL_ERROR; pMod = new EchoModule();//sqlite3_malloc(sizeof(EchoModule)); pMod.interp = interp; sqlite3_create_module_v2( db, "echo", echoModule, pMod, moduleDestroy ); return TCL.TCL_OK; }
/* ** Usage: testvfs VFSNAME ?SWITCHES? ** ** Switches are: ** ** -noshm BOOLEAN (True to omit shm methods. Default false) ** -default BOOLEAN (True to make the vfs default. Default false) ** ** This command creates two things when it is invoked: an SQLite VFS, and ** a Tcl command. Both are named VFSNAME. The VFS is installed. It is not ** installed as the default VFS. ** ** The VFS passes all file I/O calls through to the underlying VFS. ** ** Whenever the xShmMap method of the VFS ** is invoked, the SCRIPT is executed as follows: ** ** SCRIPT xShmMap FILENAME ID ** ** The value returned by the invocation of SCRIPT above is interpreted as ** an SQLite error code and returned to SQLite. Either a symbolic ** "SQLITE_OK" or numeric "0" value may be returned. ** ** The contents of the shared-memory buffer associated with a given file ** may be read and set using the following command: ** ** VFSNAME shm FILENAME ?NEWVALUE? ** ** When the xShmLock method is invoked by SQLite, the following script is ** run: ** ** SCRIPT xShmLock FILENAME ID LOCK ** ** where LOCK is of the form "OFFSET NBYTE lock/unlock shared/exclusive" */ static int testvfs_cmd( ClientData cd, Tcl_Interp interp, int objc, Tcl_Obj[] objv ){ Debugger.Break();//TODO // sqlite3_vfs tvfs_vfs = new sqlite3_vfs( // 2, /* iVersion */ // 0, /* szOsFile */ // 0, /* mxPathname */ // null, /* pNext */ // null, /* zName */ // 0, /* pAppData */ // tvfsOpen, /* xOpen */ // tvfsDelete, /* xDelete */ // tvfsAccess, /* xAccess */ // tvfsFullPathname, /* xFullPathname */ //#if !SQLITE_OMIT_LOAD_EXTENSION // tvfsDlOpen, /* xDlOpen */ // tvfsDlError, /* xDlError */ // tvfsDlSym, /* xDlSym */ // tvfsDlClose, /* xDlClose */ //#else // null, /* xDlOpen */ // null, /* xDlError */ // null, /* xDlSym */ // null, /* xDlClose */ //#endif //* SQLITE_OMIT_LOAD_EXTENSION */ // tvfsRandomness, /* xRandomness */ // tvfsSleep, /* xSleep */ // tvfsCurrentTime, /* xCurrentTime */ // null, /* xGetLastError */ // null, /* xCurrentTimeInt64 */ // null, null, null // ); // Testvfs p; /* New object */ // sqlite3_vfs pVfs; /* New VFS */ // string zVfs; // int nByte; /* Bytes of space to allocate at p */ // int i; // int isNoshm = 0; /* True if -noshm is passed */ // int isDefault = 0; /* True if -default is passed */ // int szOsFile = 0; /* Value passed to -szosfile */ // int mxPathname = -1; /* Value passed to -mxpathname */ // int iVersion = 2; /* Value passed to -iversion */ // if( objc<2 || 0!=(objc%2) ) goto bad_args; // for(i=2; i<objc; i += 2){ // int nSwitch; // string zSwitch; // zSwitch = TCL.Tcl_GetStringFromObj(objv[i], &nSwitch); // if( nSwitch>2 && 0==strncmp("-noshm", zSwitch, nSwitch) ){ // if ( TCL.Tcl_GetBooleanFromObj( interp, objv[i + 1], &isNoshm ) ) // { // return TCL.TCL_ERROR; // } // } // else if( nSwitch>2 && 0==strncmp("-default", zSwitch, nSwitch) ){ // if ( TCL.Tcl_GetBooleanFromObj( interp, objv[i + 1], &isDefault ) ) // { // return TCL.TCL_ERROR; // } // } // else if( nSwitch>2 && 0==strncmp("-szosfile", zSwitch, nSwitch) ){ // if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &szOsFile ) ) // { // return TCL.TCL_ERROR; // } // } // else if( nSwitch>2 && 0==strncmp("-mxpathname", zSwitch, nSwitch) ){ // if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &mxPathname ) ) // { // return TCL.TCL_ERROR; // } // } // else if( nSwitch>2 && 0==strncmp("-iversion", zSwitch, nSwitch) ){ // if ( TCL.Tcl_GetIntFromObj( interp, objv[i + 1], &iVersion ) ) // { // return TCL.TCL_ERROR; // } // } // else{ // goto bad_args; // } // } // if( szOsFile<sizeof(TestvfsFile) ){ // szOsFile = sizeof(TestvfsFile); // } // zVfs = TCL.Tcl_GetString(objv[1]); // nByte = sizeof(Testvfs) + strlen(zVfs)+1; // p = (Testvfs )ckalloc(nByte); // memset(p, 0, nByte); // p.iDevchar = -1; // p.iSectorsize = -1; // /* Create the new object command before querying SQLite for a default VFS // ** to use for 'real' IO operations. This is because creating the new VFS // ** may delete an existing [testvfs] VFS of the same name. If such a VFS // ** is currently the default, the new [testvfs] may end up calling the // ** methods of a deleted object. // */ // TCL.Tcl_CreateObjCommand( interp, zVfs, testvfs_obj_cmd, p, testvfs_obj_del ); // p.pParent = sqlite3_vfs_find(""); // p.interp = interp; // p.zName = (char )&p[1]; // memcpy(p.zName, zVfs, strlen(zVfs)+1); // pVfs = new sqlite3_vfs();//(sqlite3_vfs )ckalloc(sizeof(sqlite3_vfs)); // tvfs_vfs.CopyTo(pVfs);//memcpy( pVfs, &tvfs_vfs, sizeof( sqlite3_vfs ) ); // pVfs.pAppData = p; // pVfs.iVersion = iVersion; // pVfs.zName = p.zName; // pVfs.mxPathname = p.pParent.mxPathname; // if( mxPathname>=0 && mxPathname<pVfs.mxPathname ){ // pVfs.mxPathname = mxPathname; // } // pVfs.szOsFile = szOsFile; // p.pVfs = pVfs; // p.isNoshm = isNoshm; // p.mask = TESTVFS_ALL_MASK; // sqlite3_vfs_register(pVfs, isDefault); // return TCL.TCL_OK; // bad_args: // TCL.Tcl_WrongNumArgs(interp, 1, objv, "VFSNAME ?-noshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?"); return TCL.TCL_ERROR; }
private void RemoveForClient(IMyReplicable replicable, EndpointId clientEndpoint, ClientData clientData, bool sendDestroyToClient) { if (sendDestroyToClient) { SendReplicationDestroy(replicable, clientEndpoint); } RemoveClientReplicable(replicable, clientData); Console.WriteLine(String.Format("Sending replication destroy: {0}", GetNetworkIdByObject(replicable))); }
public ServerDeclineInvite(ClientData source, int destinationId, ISessionsRepository sessionsRepository, IPacketFormatter packetFormatter) : base(source, sessionsRepository, packetFormatter, Operation.Invite, Status.Decline) { _destinationId = destinationId; }
private void RemoveClientReplicable(IMyReplicable replicable, ClientData clientData) { foreach (var g in m_replicableGroups[replicable]) { g.DestroyClientData(clientData.State); clientData.StateGroups.Remove(g); } clientData.Replicables.Remove(replicable); }
/* ** sqlite3_intarray_bind INTARRAY ?VALUE ...? ** ** Invoke the sqlite3_intarray_bind interface on the given array of integers. */ static int test_intarray_bind( ClientData clientData, /* Not used */ Tcl_Interp interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj[] objv /* Command arguments */ ) { sqlite3_intarray pArray; int rc = SQLITE_OK; int i, n; sqlite3_int64[] a; if ( objc < 2 ) { TCL.Tcl_WrongNumArgs( interp, 1, objv, "INTARRAY" ); return TCL.TCL_ERROR; } pArray = (sqlite3_intarray)sqlite3TestTextToPtr( interp, TCL.Tcl_GetString( objv[1] ) ); n = objc - 2; #if !SQLITE_OMIT_VIRTUALTABLE a = new sqlite3_int64[n];//sqlite3_malloc( sizeof(a[0])*n ); //if( a==0 ){ // Tcl_AppendResult(interp, "SQLITE_NOMEM", (char*)0); // return TCL_ERROR; //} for ( i = 0; i < n; i++ ) { //a[i] = 0; TCL.Tcl_GetWideIntFromObj( null, objv[i + 2], out a[i] ); } rc = sqlite3_intarray_bind( pArray, n, a, sqlite3_free ); if ( rc != SQLITE_OK ) { TCL.Tcl_AppendResult( interp, sqlite3TestErrorName( rc ), null ); return TCL.TCL_ERROR; } #endif return TCL.TCL_OK; }
public Client(ClientData cd) { Load(cd); }
public int[] GetClientServerGroups(ClientData client) { if (client == null) throw new ArgumentNullException(nameof(client)); Log.Write(Log.Level.Debug, "QC GetClientServerGroups called"); var response = tsClient.ServerGroupsOfClientDbId(client); if (!response.Any()) return new int[0]; return response.Select(csg => csg.ServerGroupId).ToArray(); }
public bool Save(string userId) { try { using (OAuthDataContext context = OAuthContextHelper.GetContext()) { ClientData data; if (ClientId > 0) { data = context.ClientDatas.FirstOrDefault(c => c.client_id == ClientId); if (data == null) { throw new ArgumentOutOfRangeException("Client Not Found for ClientID"); } } else { data = new ClientData(); if (ApiKey == Guid.Empty) { GenerateApiKey(); } if (ApiSecret == Guid.Empty) { GenerateApiSecret(); } } data.client_name = Name; data.callback_url = Callback; data.api_key = ApiKey; data.api_secret = ApiSecret; data.modified_by = userId; data.date_modified = DateTime.Now; data.active = Active; if (data.client_id <= 0) { data.created_by = userId; data.date_created = DateTime.Now; if (Scopes != null) { foreach (var scope in Scopes) { data.ClientScopeDatas.Add(new ClientScopeData { scope_id = scope.ScopeId, created_by = userId, date_created = DateTime.Now, modified_by = userId, date_modified = DateTime.Now, active = true }); } } context.ClientDatas.InsertOnSubmit(data); } else { var scopeIDRemove = data.ClientScopeDatas.Select(cs => cs.scope_id).Where(cs => !Scopes.Select(s => s.ScopeId).Contains(cs)).ToArray(); foreach (var scopeId in scopeIDRemove) { var scopeToRemove = data.ClientScopeDatas.Where(cs => cs.scope_id == scopeId).FirstOrDefault(); if (scopeToRemove != null) { context.ClientScopeDatas.DeleteOnSubmit(scopeToRemove); } } var scopeIdAdd = Scopes.Select(s => s.ScopeId).Where(s => !data.ClientScopeDatas.Select(cs => cs.scope_id).Contains(s)); foreach (var scopeId in scopeIdAdd) { data.ClientScopeDatas.Add( new ClientScopeData { scope_id = scopeId, created_by = userId, modified_by = userId, date_created = DateTime.Now, date_modified = DateTime.Now, active = true } ); } } context.SubmitChanges(); if (data.client_id > 0) { Load(data); return(true); } return(false); } } catch (Exception ex) { throw new Exception("An error occurred when saving client.", ex); } }
public void SendMessage(string message, ClientData client) => tsClient.SendMessage(message, client);
internal void SendNearbyDataToClient(ClientData client, GameData gameData) { }
/* ** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: ** ** sqlite3_declare_vtab DB SQL */ static int declare_vtab( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj[] objv /* Command arguments */ ) { sqlite3 db = null; int rc; if ( objc != 3 ) { TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB SQL" ); return TCL.TCL_ERROR; } if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 ) return TCL.TCL_ERROR; rc = sqlite3_declare_vtab( db, TCL.Tcl_GetString( objv[2] ) ); if ( rc != SQLITE_OK ) { TCL.Tcl_SetResult( interp, sqlite3_errmsg( db ), TCL.TCL_VOLATILE ); return TCL.TCL_ERROR; } return TCL.TCL_OK; }
void ISetWebsocketContext.SetClient(ClientData clientData) { this.ClientData = clientData; }