private void ProcessStatusMessage(ChangeMessage message) { if (message.ConnectionClosed != null) { Connected = message.ConnectionClosed == false; } }
void Start() { activeCharacter = this.transform.parent.parent.parent.Find("CharacterIcon"). GetComponent <ActivePlayer>().player.GetComponent <UnityCharacter>(); message = this.transform.parent.parent.parent.Find("MessageBox").GetComponent <ChangeMessage>(); this.GetComponent <Button>().onClick.AddListener(Cast); }
private async Task PlaceOrdersFromEachStrategy( ChangeMessage change, double bank) { var bankPerStrategy = bank / _strategies.Count; if (change.Operation == "mcm") { var allOrders = new List <LimitOrder>(); change.MarketChanges.ForEach( mc => _strategies.ForEach( s => { var o = s.GetOrders(mc, Math.Round(bankPerStrategy, 2)); if (o != null) { allOrders.AddRange(o); } })); if (allOrders.Count > 0) { await _orderManager.Place(allOrders); } } }
public void OnSetArrivalTimeEpochMillisecondsIsSet() { var message = new ChangeMessage(); var datetime = DateTime.Parse("2020-02-14 19:17:33.123", new NumberFormatInfo()); message.SetArrivalTime(datetime); Assert.Equal(1581707853123, message.ArrivalTime); }
private void ProcessMessage(ChangeMessage message) { message.SetArrivalTime(DateTime.UtcNow); if (ProcessMessageMap.ContainsKey(message.Operation)) { ProcessMessageMap[message.Operation](message); } SetClocks(message); }
private void Start() { message = messageBox.GetComponent <ChangeMessage>(); dialogSystem = DialogSystemObject.GetComponent <DialogSystem>(); questSystem = GameObject.Find("QuestSystem").GetComponent <QuestSystem>(); saveManager = GameObject.Find("Saving").GetComponent <SaveManager>(); dialogSystem = GameObject.Find("DialogSystem").GetComponent <DialogSystem>(); dialogSystem.DialogEndedEvent += OnDialogEnded; }
public void OnChange(ChangeMessage change) { if (change is null) { return; } change.MarketChanges?.ForEach(mc => OnMarketChange(mc, change.PublishTime)); change.OrderChanges?.ForEach(OnOrderChange); }
public void OnOrderChange(ChangeMessage <OrderMarketChange> changeMessage) { if (changeMessage.IsStartOfNewSubscription) { //clear cache _markets.Clear(); } if (changeMessage.Items != null) { //lazy build events List <OrderMarketChangedEventArgs> batch = BatchOrderMarketsChanged == null ? null : new List <OrderMarketChangedEventArgs>(changeMessage.Items.Count); foreach (OrderMarketChange marketChange in changeMessage.Items) { bool isImage = marketChange.FullImage == true; if (isImage) { // Clear market from cache if it is being re-imaged OrderMarket removed; _markets.TryRemove(marketChange.Id, out removed); } OrderMarket market = OnOrderMarketChange(marketChange); if (IsOrderMarketRemovedOnClose && market.IsClosed) { //remove on close OrderMarket removed; _markets.TryRemove(market.MarketId, out removed); } //lazy build events if (batch != null || OrderMarketChanged != null) { OrderMarketChangedEventArgs arg = new OrderMarketChangedEventArgs() { Change = marketChange, OrderMarket = market }; if (OrderMarketChanged != null) { DispatchOrderMarketChanged(arg); } if (batch != null) { batch.Add(arg); } } } if (batch != null) { DispatchBatchOrderMarketsChanged(new BatchOrderMarketsChangedEventArgs() { Changes = batch }); } } }
// Start is called before the first frame update void Start() { fightSystem = GameObject.Find("FightSystem").GetComponent <FightSystem>(); thisReceiver = this.GetComponent <UnityCharacter>().Character; unityInventory = GameObject.Find("Canvas").transform.Find("Inventory").GetComponent <UnityInventory>(); unitySpellbook = GameObject.Find("Canvas").transform.Find("SpellBook").GetComponent <UnitySpellbook>(); message = GameObject.Find("Canvas").transform.Find("MessageBox").GetComponent <ChangeMessage>(); dialogSystem = GameObject.Find("DialogSystem").GetComponent <DialogSystem>(); questSystem = GameObject.Find("QuestSystem").GetComponent <QuestSystem>(); }
public override void HandleWorldChange(Change change) { // can the player see the change? if (!CanSeeChange(change)) { return; } // Send object data for an object that comes to the environment if (change is ObjectMoveChange) { var c = (ObjectMoveChange)change; var dst = c.Destination as EnvironmentObject; if (dst != null && c.Source != c.Destination && (dst.VisibilityMode == VisibilityMode.AllVisible || dst.VisibilityMode == VisibilityMode.GlobalFOV)) { var newObject = c.Object; var vis = m_player.GetObjectVisibility(newObject); Debug.Assert(vis != ObjectVisibility.None); newObject.SendTo(m_player, vis); } } // When an item is equipped by a non-controllable, the item isn't known to the client. // Thus we need to send the data of the item here, before sending the property change message. // XXX should there be some kind of "visibility-changed" event? if (change is PropertyChange) { var c = (PropertyChange)change; if (c.PropertyID == PropertyID.IsEquipped) { var item = (ItemObject)c.Object; if (item.IsEquipped) { var equipper = (LivingObject)item.Container; if (m_player.IsController(equipper) == false) { item.SendTo(m_player, ObjectVisibility.Public); } } } } var changeMsg = new ChangeMessage() { ChangeData = change.ToChangeData() }; Send(changeMsg); }
public SubscriptionSpy WithMarketChanges(IEnumerable <MarketChange> marketChanges) { var change = new ChangeMessage { Operation = "mcm", ChangeType = "mc", MarketChanges = marketChanges.ToList(), PublishTime = PublishTime, }; Messages.Add(change); return(this); }
private void SetClocks(ChangeMessage message) { if (message.Id == null) { return; } if (!_subscriptionMessages.ContainsKey((int)message.Id)) { return; } _subscriptionMessages[(int)message.Id] .WithInitialClock(message.InitialClock) .WithClock(message.Clock); }
public object Clone() { ChangeMessage changeMessage = MemberwiseClone() as ChangeMessage; if (data != null) { changeMessage.data = data.Clone() as ChangeMessageGameData; } if (code != null) { changeMessage.code = code.Clone() as ChangeMessageCode; } return(changeMessage); }
public void OnMarketChange(ChangeMessage <MarketChange> changeMessage) { if (changeMessage.IsStartOfNewSubscription) { //clear cache _markets.Clear(); } if (changeMessage.Items != null) { //lazy build events List <MarketChangedEventArgs> batch = BatchMarketsChanged == null ? null : new List <MarketChangedEventArgs>(changeMessage.Items.Count); foreach (MarketChange marketChange in changeMessage.Items) { Market market = OnMarketChange(marketChange); if (IsMarketRemovedOnClose && market.IsClosed) { //remove on close Market removed; _markets.TryRemove(market.MarketId, out removed); } //lazy build events if (batch != null || MarketChanged != null) { MarketChangedEventArgs arg = new MarketChangedEventArgs() { Change = marketChange, Market = market }; if (MarketChanged != null) { DispatchMarketChanged(arg); } if (batch != null) { batch.Add(arg); } } } if (batch != null) { DispatchBatchMarketsChanged(new BatchMarketsChangedEventArgs() { Changes = batch }); } } }
public SubscriptionSpy WithOrderChange(OrderChange orderChange) { var change = new ChangeMessage { Operation = "orc", ChangeType = "oc", OrderChanges = new List <OrderChange> { orderChange }, PublishTime = PublishTime, }; Messages.Add(change); return(this); }
public SubscriptionSpy WithMarketChange(MarketChange marketChange) { var change = new ChangeMessage { Operation = "mcm", ChangeType = "mc", MarketChanges = new List <MarketChange> { marketChange }, PublishTime = PublishTime, }; Messages.Add(change); return(this); }
public override void HandleWorldChange(Change change) { var changeMsg = new ChangeMessage() { ChangeData = change.ToChangeData() }; Send(changeMsg); if (change is ObjectCreatedChange) { var c = (ObjectCreatedChange)change; var newObject = c.Object; newObject.SendTo(m_player, ObjectVisibility.All); } }
virtual public void Change() { ChangeMessage message = NewChangeMessage(); if (message == null) { return; } Server server = device.Server; MemoryStream stream = new MemoryStream(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ChangeMessage), settings); serializer.WriteObject(stream, message); String json = System.Text.Encoding.Default.GetString(stream.GetBuffer()); server.SendMessage(json); }
private void Change(ChangeMessage message) { Console.WriteLine($"Change :: {message.File}"); // This is not optimal.. a small change should require recreating the file var localPath = Path.Combine(_directory, message.File); if (File.Exists(localPath)) { File.Delete(localPath); } var removed = _hashSet.Where(kvp => kvp.Value.File == message.File).Select(kvp => kvp.Key).ToArray(); foreach (var remove in removed) { _hashSet.Remove(remove); } }
private void EventProcessingIteration(RequestStopHandler requestStopHandler) { if (!_eventQueue.TryTake(out var pluginEvent, 100)) { return; } switch (pluginEvent.PluginEventType) { case PluginEventType.Change: ChangeMessage?.Invoke(pluginEvent.Data); break; case PluginEventType.Module: ModuleMessage?.Invoke(pluginEvent.Data); break; default: Log.Error("Unknown event type received in {@Event}", pluginEvent); break; } }
void _networkChangeDetector_ProxyChanged(string name, NetworkInfo networkInfo, ProxySettings proxySettings, string reason) { try { log.DebugFormat("ProxyChanged event: {0}, network {1}, proxy {2}, reason", name, networkInfo, proxySettings, reason); lastUpdateTime = DateTime.Now; _activeConfiguration = _configurationsList.First((c) => c.Name == name); this.interfaceName = networkInfo != null ? networkInfo.IfName : "N/A"; this.addresses = networkInfo != null?String.Join(", ", networkInfo.IP) : ""; this.reason = reason; _currentNetworks = _networkChangeDetector.CurrentNetworks; _currentNetwork = networkInfo != null?_currentNetworks.FirstOrDefault((n) => networkInfo.IfName == n.IfName) : null; _currentProxySettings = proxySettings; RaisePropertyChanged("LastUpdateTime"); RaisePropertyChanged("ActiveConfiguration"); RaisePropertyChanged("InterfaceName"); RaisePropertyChanged("Addresses"); RaisePropertyChanged("Reason"); RaisePropertyChanged("CurrentNetworks"); RaisePropertyChanged("CurrentNetwork"); RaisePropertyChanged("CurrentProxySettings"); log.Debug("Sending ChangeMessage"); ChangeMessage msg = new ChangeMessage() { ConfName = name, Network = networkInfo, ProxySettings = proxySettings, Reason = reason }; Messenger.Default.Send <ChangeMessage>(msg); } catch (Exception ex) { log.Error("Failure", ex); } }
private async Task ChangedFile(FileInfo file) { for (int jj = 0; jj < NumberOfRetries; ++jj) { try { using (var stream = File.OpenRead(file.FullPath)) { var size = stream.Length; var message = new ChangeMessage(file.Name, size); _messageCollection.Add(message, _cancellationToken); var crypto = new SHA256CryptoServiceProvider(); for (int ii = 0; ii < (size / BlockSize) + 1; ii++) { var buffer = new byte[BlockSize]; var read = await stream.ReadAsync(buffer, 0, BlockSize, _cancellationToken); var base64 = Convert.ToBase64String(buffer); var hash = Convert.ToBase64String(crypto.ComputeHash(buffer)); var partMessage = new PartMessage(file.Name, ii * BlockSize, read, hash); var hashMessage = new HashMessage(file.Name, ii * BlockSize, read, hash, base64); _messageCollection.Add(partMessage, _cancellationToken); _messageCollection.Add(hashMessage, _cancellationToken); } } break; } catch (IOException ex) when(jj <= NumberOfRetries) { Console.WriteLine($"Retrying in {DelayOnRetries / 1000}s. IO Error = {ex.Message}"); await Task.Delay(DelayOnRetries); } } }
public void OnMarketChange(ChangeMessage<MarketChange> changeMessage) { marketCache.OnMarketChange(changeMessage); }
public void OnOrderChange(ChangeMessage<OrderMarketChange> changeMessage) { orderCache.OnOrderChange(changeMessage); }
private void ProcessConnectionMessage(ChangeMessage message) { ConnectionId = message.ConnectionId; Connected = true; }
public void SendMessage(ChangeMessage changeMessage) { GameReceiveMessageEvent.Invoke(changeMessage); }
void _networkChangeDetector_ProxyChanged(string name, NetworkInfo networkInfo, ProxySettings proxySettings, string reason) { try { log.DebugFormat("ProxyChanged event: {0}, network {1}, proxy {2}, reason", name, networkInfo, proxySettings, reason); lastUpdateTime = DateTime.Now; _activeConfiguration = _configurationsList.First((c) => c.Name == name); this.interfaceName = networkInfo != null ? networkInfo.IfName : "N/A"; this.addresses = networkInfo != null ? String.Join(", ", networkInfo.IP) : ""; this.reason = reason; _currentNetworks = _networkChangeDetector.CurrentNetworks; _currentNetwork = networkInfo != null ? _currentNetworks.FirstOrDefault((n) => networkInfo.IfName == n.IfName) : null; _currentProxySettings = proxySettings; RaisePropertyChanged("LastUpdateTime"); RaisePropertyChanged("ActiveConfiguration"); RaisePropertyChanged("InterfaceName"); RaisePropertyChanged("Addresses"); RaisePropertyChanged("Reason"); RaisePropertyChanged("CurrentNetworks"); RaisePropertyChanged("CurrentNetwork"); RaisePropertyChanged("CurrentProxySettings"); log.Debug("Sending ChangeMessage"); ChangeMessage msg = new ChangeMessage() { ConfName = name, Network = networkInfo, ProxySettings = proxySettings, Reason = reason }; Messenger.Default.Send<ChangeMessage>(msg); } catch (Exception ex) { log.Error("Failure", ex); } }
protected virtual void HandleChangeMessage(ChangeMessage Message) { Message.UpdatedObject.ResolveResources(resourceManager, false); Message.UpdatedObject.DecompressResources(); }
public void OnMarketChange(ChangeMessage <MarketChange> changeMessage) { marketCache.OnMarketChange(changeMessage); }
public void NotifyChange(ChangeMessage message, GameObject obj, params object[] opData) { changeController.OnNotification(message, obj, opData); }
void IChangeMessageHandler.OnMarketChange(ChangeMessage <MarketChange> change) { _marketCache.OnMarketChange(change); }
public void OnOrderChange(ChangeMessage <OrderMarketChange> changeMessage) { orderCache.OnOrderChange(changeMessage); }
void IChangeMessageHandler.OnOrderChange(ChangeMessage <OrderMarketChange> change) { _orderCache.OnOrderChange(change); }