X13.Periphery.MsDevice.PublishTopic C# (CSharp) Method

PublishTopic() private method

private PublishTopic ( Topic topic, TopicChanged param ) : void
topic Topic
param TopicChanged
return void
    private void PublishTopic(Topic topic, TopicChanged param) {
      if(topic.valueType==null || topic==Owner) {
        return;
      }
      if(param.Art==TopicChanged.ChangeArt.Add) {
        if(topic.valueType==typeof(SmartTwi)) { // || (topic.parent!=null && topic.parent.valueType==typeof(SmartTwi))
          return;   // processed from SmartTwi
        }
        if(topic.valueType==typeof(TWIDriver)) {  //  || (topic.parent!=null && topic.parent.valueType==typeof(TWIDriver))
          return;   // processed from TWIDriver
        }
        GetTopicInfo(topic);
        return;
      }
      if(topic.name=="_via") {
        if(_gate==null) {
          if(string.IsNullOrEmpty(via)) {
            MsGSerial.Rescan();
          }
        }
      }
      if(!(state==State.Connected || state==State.ASleep || state==State.AWake) || param.Visited(Owner, true)) {
        return;
      }
      if(topic.valueType==typeof(SmartTwi)) { // || (topic.parent!=null && topic.parent.valueType==typeof(SmartTwi))
        return;   // processed from SmartTwi
      }
      if(topic.valueType==typeof(TWIDriver)) {  //  || (topic.parent!=null && topic.parent.valueType==typeof(TWIDriver))
        return;   // processed from TWIDriver
      }
      TopicInfo rez=null;
      for(int i=_topics.Count-1; i>=0; i--) {
        if(_topics[i].path==topic.path) {
          rez=_topics[i];
          break;
        }
      }
      if(rez==null && param.Art==TopicChanged.ChangeArt.Value) {
        rez=GetTopicInfo(topic, true);
      }
      if(rez==null || rez.TopicId>=0xFFC0 || !rez.registred) {
        return;
      }
      if(param.Art==TopicChanged.ChangeArt.Value) {
        Send(new MsPublish(rez.topic, rez.TopicId, param.Subscription.qos));
      } else {          // Remove by device
        if(rez.it==TopicIdType.Normal) {
          Send(new MsRegister(0xFFFF, rez.path.StartsWith(Owner.path)?rez.path.Remove(0, Owner.path.Length+1):rez.path));
        }
        _topics.Remove(rez);
      }
    }
    internal void PublishWithPayload(Topic t, byte[] payload) {