public Tuple <SessionID, bool> add(SharedStateBase sharedState, SharedStateType mode)
        {
            switch (mode)
            {
            case SharedStateType.USE_COUPLING_MODE:
                useCouplingMode.Add(sharedState);
                return(new Tuple <SessionID, bool>(m_publicSessionID, m_muted));

            case SharedStateType.NEVER_SHARE:
                neverShare.Add(sharedState);
                return(new Tuple <SessionID, bool>(m_privateSessionID, false));

            case SharedStateType.ALWAYS_SHARE:
                alwaysShare.Add(sharedState);
                return(new Tuple <SessionID, bool>(m_publicSessionID, false));

            case SharedStateType.SHARE_WITH_ALL:
                shareWithAll.Add(sharedState);
                string    name = "all";
                SessionID sid  = new SessionID(0, name, false);
                return(new Tuple <SessionID, bool>(sid, false));
            }

            return(new Tuple <SessionID, bool>(m_privateSessionID, true));
        }
예제 #2
0
 public PDUSharedState(string from, string to, SharedStateType sharedStateType, string target, string value)
     : base(from, to)
 {
     SharedStateType = sharedStateType;
     Target          = target;
     Value           = value;
 }
예제 #3
0
        public SharedState(string pName, T pValue = default(T), SharedStateType pMode = SharedStateType.USE_COUPLING_MODE) : base(pName, pMode)
        {
            m_value = pValue;
            MessageBuffer mb = new MessageBuffer();

            SharedStateSerializer.serializeWithType(ref mb, m_value);
            subscribe(mb);
        }
예제 #4
0
        public SharedStateBase(string name, SharedStateType mode, string className = "SharedState")
        {
            m_className  = className;
            variableName = name;
            var news = SharedStateManager.Instance.add(this, mode);

            sessionID = news.Item1;
            muted     = news.Item2;
        }
예제 #5
0
        public static PDUSharedState Parse(string[] fields)
        {
            if (fields.Length < 6)
            {
                throw new PDUFormatException("Invalid field count.", Reassemble(fields));
            }
            try {
                SharedStateType sharedStateType = SharedStateType.Unknown;
                switch (fields[3])
                {
                case "SC":
                    sharedStateType = SharedStateType.Scratchpad;
                    break;

                case "BC":
                    sharedStateType = SharedStateType.BeaconCode;
                    break;

                case "VT":
                    sharedStateType = SharedStateType.VoiceType;
                    break;

                case "TA":
                    sharedStateType = SharedStateType.TempAlt;
                    break;
                }
                return(new PDUSharedState(
                           fields[0],
                           fields[1],
                           sharedStateType,
                           fields[4],
                           fields[5]
                           ));
            }
            catch (Exception ex) {
                throw new PDUFormatException("Parse error.", Reassemble(fields), ex);
            }
        }