コード例 #1
0
ファイル: Udp.cs プロジェクト: marlonnn/TSP_FCT
        public void UdpTxStart()
        {
            while (NeedRunning)
            {
                try
                {
                    List <Original> originalData = txQueue.PopAll();
                    if (originalData != null)
                    {
                        if (originalData.Count != 0)
                        {
                            foreach (Original original in originalData)
                            {
                                OriginalTxBytes oBytes    = original as OriginalTxBytes;
                                UdpNetClient    udpClient = udpNetClients[oBytes.RemoteIpEndPoint.ToString()];
                                udpClient.Send(oBytes.Data);
                            }
                        }
                    }

                    Thread.Sleep(20);
                }
                catch (System.Exception ex)
                {
                }
            }
        }
コード例 #2
0
        public void ExecuteEncoderInternal()
        {
            LogHelper.GetLogger("job").Debug("Begin ProtocolFactory.ExecuteEncoderInternal()");
            List <BaseMessage> listMsg = txMsgQueue.PopAll();

            if (listMsg.Count == 0)
            {
                return;
            }
            else
            {
                foreach (BaseMessage msg in listMsg)
                {
                    //组包放到发送数据原始队列TxQueue中
                    byte[]          framData        = frameProtocol.EnPackage(msg, 0);
                    OriginalTxBytes originalTxbytes = new OriginalTxBytes();
                    originalTxbytes.RemoteIpEndPoint = String2IPEndPoint(msg.IpAndPort);
                    originalTxbytes.Data             = framData;
                    txQueue.Push(originalTxbytes);
                }
            }

            LogHelper.GetLogger("job").Debug("Finish ProtocolFactory.ExecuteEncoderInternal()");
        }