Ejemplo n.º 1
0
        public override async Task Connect()
        {
            await base.Connect();

            this.SocketReceiveWrapper("connect", (data) =>
            {
                this.Connected = true;
            });

            this.SocketReceiveWrapper("realTimeTreat", (data) =>
            {
                if (data != null)
                {
                    TreatStreamEvent tsEvent = SerializerHelper.DeserializeFromString <TreatStreamEvent>(data.ToString());
                    if (tsEvent != null)
                    {
                        this.service.DonationOccurred(tsEvent);
                        Task.Run(async() =>
                        {
                            UserDonationModel donation = tsEvent.ToGenericDonation();
                            await EventCommand.ProcessDonationEventCommand(donation, OtherEventTypeEnum.TreatStreamDonation);
                        });
                    }
                }
            });

            this.SocketReceiveWrapper("error", (errorData) =>
            {
                MixItUp.Base.Util.Logger.Log(errorData.ToString());
                this.service.WebSocketDisconnectedOccurred();
            });

            this.SocketReceiveWrapper("disconnect", (errorData) =>
            {
                MixItUp.Base.Util.Logger.Log(errorData.ToString());
                this.service.WebSocketDisconnectedOccurred();
            });

            for (int i = 0; i < 10 && !this.Connected; i++)
            {
                await Task.Delay(1000);
            }

            if (this.Connected)
            {
                this.service.WebSocketConnectedOccurred();
            }
        }
Ejemplo n.º 2
0
 public void DonationOccurred(TreatStreamEvent eventData)
 {
     this.OnDonationOccurred(this, eventData);
 }