예제 #1
0
        public WsIQClientRx()
        {
            // TODO INJECT
            _ws            = new WebSocketWrapper();
            _epoch         = new Epoch();
            _randomNumbers = new RandomNumbers();

            MessagesFeed = Observable
                           .FromEventPattern <OnMessageEventHandler, WsRecievemessageEventArgs>(
                h => _ws.OnMessage += h,
                h => _ws.OnMessage -= h)
                           //.ObserveOn(NewThreadScheduler.Default)
                           .Map((e) =>
            {
                var serializedMessage = e.EventArgs.Message;
                var iQmessage         = JsonConvert.DeserializeObject <IQOptionMessage>(serializedMessage);
                return(iQmessage);
            });

            _onConnection = Observable
                            .FromEventPattern <OnConnectedEventHandler, EventArgs>(
                h => _ws.OnConnected += h,
                h => _ws.OnConnected -= h)
                            .Map(e => e.EventArgs)
                            .Replay();

            _onConnectionConnection = _onConnection.Connect();

            //TODO DO THIS IN THE IQCLient
            _ssidDualChannel = new SsidPublisherChannel(this);

            _heartBeatDualChannel = new HeartBeatDualChannel(this);

            _wsMessagesSubscription = _heartBeatDualChannel.ChannelFeed
                                      .Map(heartbeat => _heartBeatDualChannel.SendMessage(new HeartBeatOutputMessage(_epoch.EpochMilliSeconds, heartbeat.HeartbeatTime)))
                                      .Subscribe();

            _candleGeneratedDualChannel = new CandleGeneratedDualChannel(this);

            _serverTimeSync = new TimeSyncListenerChannel(this);

            _profileChannel = new ProfileListenerChannel(this);

            _listInfoDataChannelListener = new ListInfoDataListenerChannel(this);

            _buyV2ChannelPublisher = new BuyV2Channel(this, _epoch);
        }
예제 #2
0
 public RandomHostedService(IRandomNumbers randomNumbers, IFile file)
 {
     this.randomNumbers = randomNumbers;
     this.file          = file;
 }