コード例 #1
0
ファイル: Relationships.cs プロジェクト: HassanEmam/CPMcon
 public Relationships(Activity pred, Activity succ, relType relationType, int lag)
 {
     this.Pred             = pred;
     this.Succ             = succ;
     this.RelationshipType = relationType;
     this.Lag = lag;
 }
コード例 #2
0
        public void publish <T>(string uri, T data) where T : IMessage
        {
            FcpMessage fcp = new FcpMessage();

            fcp.DstUri = (m_path.abs_uri(uri));
            fcp.SrcUri = (m_path.abs_uri());
            fcp.Type   = (FcpType.Publish);
            fcp.Data   = Encoding.ASCII.GetString(data.ToByteArray());
            relType rel = m_path.relation(uri);

            //if protected unsafe List<Tuple<string, Node_*>> Table { get => table; set => table = value; }

            if (rel == relType.child)
            {
                fcp.Direction = (0);
                handleMsg(fcp);
            }
            else
            {
                fcp.Direction = (1);
                sendMsg(fcp);
            }

            Logger.DebugFormat("publishEx -----------------------");
            fcp.DstUri    = (m_path.abs_uri(uri));
            fcp.Direction = (1);
            fcp.Type      = (FcpType.ExtPublish);
            //额外发送一个消息给master,由master转发给订阅者
            sendMsg(fcp);
            Logger.DebugFormat("publish end-----------------------");
        }
コード例 #3
0
        public override int handleMsg(FcpMessage fcp)
        {
            string  uri = fcp.DstUri;
            relType rel = m_path.relation(uri);

            if (rel == relType.parent)
            {
                sendMsg(fcp);
            }
            else if (rel == relType.self)
            {
                handleLocal(fcp);
            }
            //与自己与父亲有关
            else if (rel == relType.brother)
            {
                //handleLocal(fcp);
                if (fcp.Direction == 1)
                {
                    sendMsg(fcp);
                }
                else
                {
                    handleLocal(fcp);
                }
            }
            //与自己无关,只与孩子有关
            else if (rel == relType.child)
            {
                FcpMessage t_fcp = fcp;
                t_fcp.Direction = 0;
                handleLocal(t_fcp);
            }

            return(0);
        }
コード例 #4
0
        public void addRelationship(IActivity pred, IActivity succ, relType reltype, int Lag)
        {
            Relationship rel = new Relationship(pred, succ, reltype, Lag);

            _addRel(rel);
        }