예제 #1
0
 private void ProcessStatusMessage(ChangeMessage message)
 {
     if (message.ConnectionClosed != null)
     {
         Connected = message.ConnectionClosed == false;
     }
 }
예제 #2
0
 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);
 }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
 private void ProcessMessage(ChangeMessage message)
 {
     message.SetArrivalTime(DateTime.UtcNow);
     if (ProcessMessageMap.ContainsKey(message.Operation))
     {
         ProcessMessageMap[message.Operation](message);
     }
     SetClocks(message);
 }
예제 #6
0
 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;
 }
예제 #7
0
 public void OnChange(ChangeMessage change)
 {
     if (change is null)
     {
         return;
     }
     change.MarketChanges?.ForEach(mc => OnMarketChange(mc, change.PublishTime));
     change.OrderChanges?.ForEach(OnOrderChange);
 }
예제 #8
0
        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
                    });
                }
            }
        }
예제 #9
0
 // 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>();
 }
예제 #10
0
        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);
        }
예제 #11
0
        public SubscriptionSpy WithMarketChanges(IEnumerable <MarketChange> marketChanges)
        {
            var change = new ChangeMessage
            {
                Operation     = "mcm",
                ChangeType    = "mc",
                MarketChanges = marketChanges.ToList(),
                PublishTime   = PublishTime,
            };

            Messages.Add(change);
            return(this);
        }
예제 #12
0
 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);
 }
예제 #13
0
    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);
    }
예제 #14
0
        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
                    });
                }
            }
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
            }
        }
예제 #18
0
파일: Indigo.cs 프로젝트: rwg0/indigo_ascom
        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);
        }
예제 #19
0
        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);
            }
        }
예제 #20
0
        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;
            }
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
        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);
                }
            }
        }
예제 #23
0
 public void OnMarketChange(ChangeMessage<MarketChange> changeMessage)
 {
     marketCache.OnMarketChange(changeMessage);
 }
예제 #24
0
 public void OnOrderChange(ChangeMessage<OrderMarketChange> changeMessage)
 {
     orderCache.OnOrderChange(changeMessage);
 }
예제 #25
0
 private void ProcessConnectionMessage(ChangeMessage message)
 {
     ConnectionId = message.ConnectionId;
     Connected    = true;
 }
예제 #26
0
 public void SendMessage(ChangeMessage changeMessage)
 {
     GameReceiveMessageEvent.Invoke(changeMessage);
 }
예제 #27
0
        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);
            }
        }
예제 #28
0
 protected virtual void HandleChangeMessage(ChangeMessage Message)
 {
     Message.UpdatedObject.ResolveResources(resourceManager, false);
     Message.UpdatedObject.DecompressResources();
 }
예제 #29
0
 public void OnMarketChange(ChangeMessage <MarketChange> changeMessage)
 {
     marketCache.OnMarketChange(changeMessage);
 }
예제 #30
0
 public void NotifyChange(ChangeMessage message, GameObject obj, params object[] opData)
 {
     changeController.OnNotification(message, obj, opData);
 }
예제 #31
0
 void IChangeMessageHandler.OnMarketChange(ChangeMessage <MarketChange> change)
 {
     _marketCache.OnMarketChange(change);
 }
예제 #32
0
 public void OnOrderChange(ChangeMessage <OrderMarketChange> changeMessage)
 {
     orderCache.OnOrderChange(changeMessage);
 }
예제 #33
0
 void IChangeMessageHandler.OnOrderChange(ChangeMessage <OrderMarketChange> change)
 {
     _orderCache.OnOrderChange(change);
 }