private void ProcessTeamMessage(ScrumTeamMessage message)
        {
            if (!this.teamsToInitialize.ContainsOrNotInit(message.TeamName))
            {
                switch (message.MessageType)
                {
                case MessageType.MemberJoined:
                    this.OnMemberJoinedMessage(message.TeamName, (ScrumTeamMemberMessage)message);
                    break;

                case MessageType.MemberDisconnected:
                    this.OnMemberDisconnectedMessage(message.TeamName, (ScrumTeamMemberMessage)message);
                    break;

                case MessageType.EstimationStarted:
                    this.OnEstimationStartedMessage(message.TeamName);
                    break;

                case MessageType.EstimationCanceled:
                    this.OnEstimationCanceledMessage(message.TeamName);
                    break;

                case MessageType.MemberEstimated:
                    this.OnMemberEstimatedMessage(message.TeamName, (ScrumTeamMemberEstimationMessage)message);
                    break;

                case MessageType.MemberActivity:
                    this.OnMemberActivityMessage(message.TeamName, (ScrumTeamMemberMessage)message);
                    break;
                }
            }
        }
        private void ScrumTeamOnMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var team = (ScrumTeam)sender;
            ScrumTeamMessage scrumTeamMessage = null;

            switch (e.Message.MessageType)
            {
            case MessageType.MemberJoined:
            case MessageType.MemberDisconnected:
            case MessageType.MemberActivity:
                var memberMessage = (MemberMessage)e.Message;
                scrumTeamMessage = new ScrumTeamMemberMessage(team.Name, memberMessage.MessageType)
                {
                    MemberName            = memberMessage.Member.Name,
                    MemberType            = memberMessage.Member.GetType().Name,
                    SessionId             = memberMessage.Member.SessionId,
                    AcknowledgedMessageId = memberMessage.Member.AcknowledgedMessageId
                };
                break;

            case MessageType.MemberEstimated:
                var memberEstimatedMessage = (MemberMessage)e.Message;
                var member = memberEstimatedMessage.Member as Member;
                if (member != null && member.Estimation != null)
                {
                    scrumTeamMessage = new ScrumTeamMemberEstimationMessage(team.Name, memberEstimatedMessage.MessageType)
                    {
                        MemberName = member.Name,
                        Estimation = member.Estimation.Value
                    };
                }

                break;

            default:
                scrumTeamMessage = new ScrumTeamMessage(team.Name, e.Message.MessageType);
                break;
            }

            if (scrumTeamMessage != null)
            {
                _observableMessages.OnNext(scrumTeamMessage);
            }
        }
        /// <summary>
        /// Executed when a Scrum team is added to collection of teams.
        /// </summary>
        /// <param name="team">The Scrum team that was added.</param>
        protected override void OnTeamAdded(ScrumTeam team)
        {
            base.OnTeamAdded(team);
            team.MessageReceived += this.ScrumTeamOnMessageReceived;

            bool isInitializingTeam = false;

            if (!this.initialized)
            {
                lock (this.teamsToInitializeLock)
                {
                    isInitializingTeam = this.teamsToInitialize != null && this.teamsToInitialize.Contains(team.Name, StringComparer.OrdinalIgnoreCase);
                }
            }

            if (!isInitializingTeam)
            {
                var teamCreatedMessage = new ScrumTeamMessage(team.Name, MessageType.TeamCreated);
                this.observableMessages.OnNext(teamCreatedMessage);
            }
        }