コード例 #1
0
        public virtual new void Start(ushort port, string ip)
        {
            base.Users = QcUser.Users;
            foreach (var v in base.Users)
            {
                var qmu = new QcMsgUser(v);
                lstUser.TryAdd(qmu.Name, qmu);
            }
            this.port = port;
            this.ip   = ip;
            this.User = QcUser.User;
            object state = new object();

            m_Timer = new System.Threading.Timer(m_Timer_Elapsed, state, 100000, 100000);
            ConnectServer();
            Task.Factory.StartNew(() =>
            {
                QcNode.NodeUpdateToDb += (o, e) =>
                {
                    //发现数据节点更新,就广播节点编码和表名
                    QcNode node = o as QcNode;
                    if (node != null)
                    {
                        client.Send(
                            QcCmd.MakeCmd(QcProtocol.QcCommand.QcDataUpdate
                                          , node.Code
                                          , node.TableName
                                          , e.ChangeType
                                          , e.Node.CodeField
                                          , (e.ChangeType == NodeChangeType.Delete) ? e.Node.ToString() : ""
                                          ));
                    }
                };
            });
        }
コード例 #2
0
 //  System.Threading.Timer keepalivetimer = null;
 public override void Start(ushort port, string ip = "")
 {
     this.port = port;
     SaveIpToDb();
     base.Users = QcUser.Users;
     this.User  = QcUser.User;
     base.Start(port);
     this.ReciveCmd        += QcMessagner_ReciveCmd;
     QcNode.NodeUpdateToDb += (o, e) =>
     {
         //发现数据节点更新,就广播节点编码和表名
         QcNode node = o as QcNode;
         if (node != null)
         {
             this.BroadcastMsg(
                 QcCmd.MakeCmd(QcProtocol.QcCommand.QcDataUpdate
                               , node.Code
                               , node.TableName
                               , e.ChangeType
                               , e.Node.CodeField
                               , (e.ChangeType == NodeChangeType.Delete)?  e.Node.ToString():""
                               ));
         }
     };
 }
コード例 #3
0
        public static bool SendMessage(this QcNode node, string name, string msg)
        {
            var u = QcUser.Users.Where(t => t.Name == name || t.UserID == name).FirstOrDefault();

            if (u == null)
            {
                return(false);
            }
            var qcmsg = new QcMsg(u.Name, msg, node.TableName, node.Code);

            if (qcmsg.Send())
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
 public QcMessagerDataUpdateEventArg(QcNode node, NodeChangeType type)
 {
     this.node = node;
     this.type = type;
 }
コード例 #5
0
ファイル: QcNode.cs プロジェクト: cug-weipeng/ExDevice-1
 public QcNodeEventArg(QcNode node, NodeChangeType type)
 {
     this.node = node;
     this.type = type;
 }