private void OnListenReceiveFromSocket()
 {
     try
     {
         int waitTime          = 100;       // 100 milliseconds
         IExecutorService exec = this.ExecutorService;
         while (!exec.WaitForShutdown(100)) // Invokes after every  10 secs
         {
             // rangesh starts here
             try
             {
                 // read from sqlite db
                 UdpFreeformEntity udp = null;//
                 this.RaiseReceiveEvent(udp);
             }
             catch (Exception e)
             {
                 ExceptionManager.Publish(e);
             }
         }
     }
     catch (Exception e)
     {
         ExceptionManager.Publish(e);
     }
 }
Beispiel #2
0
        public bool Send(IFreeformEntity_Msg request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "Send"))
            {
                bool result = default(bool);

                try
                {
                    if (request == null)
                    {
                        method.Info("Unable to send message. request is empty");
                        return(false);
                    }

                    using (UdpFreeformEntity entity = new UdpFreeformEntity())
                    {
                        entity.Address    = request.IpAddress2;
                        entity.EntityData = request;
                        result            = this.Send(entity);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
Beispiel #3
0
 protected void RaiseReceiveEvent(UdpFreeformEntity udp)
 {
     if (this.Receive != null)
     {
         this.Receive(udp);
     }
 }
 void OnTransceiver_Receive(UdpFreeformEntity item)
 {
     using (ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ff_trans_Receive"))
     {
         Log.Info(PROC, "Processing G2H Message ...");
         ExCommsExecutorFactory.ProcessMessage(item.EntityData as FFMsg_G2H);
     }
 }
Beispiel #5
0
        static void TestMeterMessage()
        {
            string msg = "[C0][A8][02][12][05][A2][B9][0F][B0][00][01][00][01][01][5B][10][2A][01][CF][00][00][00][00][00][0F][08][00][00][00][00][00][00][00][00][00][00][00][00][00][20][30][30][30][00][30][30][30][30][00][00][00][01][30][30][30][00][00][00][00][0F][49][02][01][04][00][00][31][17][02][04][00][50][45][55][03][04][00][09][40][35][04][04][00][00][00][00][05][04][00][00][00][00][06][04][00][00][00][00][29][04][00][01][51][21][2A][04][00][00][05][43][2B][04][00][00][00][00][2C][04][00][00][00][00][30][04][00][00][00][00][31][04][00][00][00][00][0F][3D][02][07][04][00][00][00][01][08][04][00][00][00][01][09][04][00][00][00][01][0A][04][00][00][00][00][0B][04][00][00][00][01][0C][04][00][00][00][00][2E][04][00][00][00][00][2F][04][00][00][00][00][0D][04][00][00][00][00][0E][04][00][00][66][00][0F][3F][02][13][05][00][00][00][85][21][14][05][00][00][15][07][82][15][05][00][00][00][00][00][16][05][00][00][00][00][00][17][04][00][00][00][03][18][04][00][00][00][52][19][04][00][00][00][00][1A][04][00][00][00][00][24][00][25][00][28][04][01][52][51][01][0F][32][02][0F][04][00][00][00][00][10][04][00][00][00][00][11][04][00][00][00][00][12][04][00][00][00][00][1F][04][00][00][00][00][20][04][00][00][00][00][26][05][00][00][00][00][00][27][04][00][00][00][00][0F][21][02][1B][04][01][19][70][00][1C][04][01][37][43][19][1D][04][00][00][00][00][1E][04][00][00][00][00][28][04][01][52][51][01][2D][00][10][0B][07][1D][03][13][24][39][1C][03][02][21][14][D6]";

            byte[]             buf    = GetBuffer(msg);
            UdpFreeformEntity  buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity    ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            IMonitorEntity_Msg mon    = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
Beispiel #6
0
        static void TestTicketMessage()
        {
            string msg =
                "[C0][A8][02][12][05][A2][BC][8A][8D][00][01][00][01][00][11][0A][02][06][00][10][0B][07][1D][03][12][57][09][1C][03][02][21][14][57]";

            byte[]             buf    = GetBuffer(msg);
            UdpFreeformEntity  buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity    ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            IMonitorEntity_Msg mon    = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
Beispiel #7
0
        //static void InitKeyExchangeStartG2H()
        //{
        //    FreeformEncryptionHelper.InitKeyExchangeStart(
        //        ModuleHelper.Current.CreateH2GMessage(IPADDR,
        //        FF_AppId_SessionIds.Security,
        //        FF_AppId_H2G_PollCodes.FreeformResponse));
        //}

        //static void InitKeyExchangeStartH2G()
        //{
        //    FreeformEncryptionHelper.InitKeyExchangeStart(
        //        ModuleHelper.Current.CreateH2GMessage(IPADDR,
        //        FF_AppId_SessionIds.Security,
        //        FF_AppId_H2G_PollCodes.FreeformResponse));
        //}

        //static void InitKeyExchangeEnd()
        //{
        //    byte[] key = new byte[] { 10, 11, 12, 34, 56, 78, 96, 89, 44 };
        //    FreeformEncryptionHelper.InitKeyExchangeEnd(
        //        ModuleHelper.Current.CreateH2GMessage(IPADDR,
        //        FF_AppId_SessionIds.Security,
        //        FF_AppId_H2G_PollCodes.FreeformResponse),
        //        key);
        //}
        static void TestPIDData()
        {
            return;

            string msg = "[C0][A8][02][10][05][A2][B9][1C][4F][00][01][00][01][00][05][1C][03][0F][01][00][FF]";

            byte[]             buf    = GetBuffer(msg);
            UdpFreeformEntity  buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity    ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            IMonitorEntity_Msg mon    = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
Beispiel #8
0
        static void TestKeyExchangePartialKey()
        {
            string msg =
                "[C0][A8][02][12][05][A2][BC][8E][01][00][01][00][01][00][0C][0B][0A][03][01][01][01][01][01][01][01][01][01][DF]";

            byte[]            buf    = GetBuffer(msg);
            UdpFreeformEntity buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity   ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            //var ff2 = new FreeformHandlerFactory();
            //ff2.ProcessMessage(ff as FFMsg_G2H);
            //IMonitorEntity_Msg mon = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
Beispiel #9
0
        static void TestEncryptedECashMessage()
        {
            string msg =
                "[C0][A8][02][12][05][A2][BC][8E][01][00][01][00][01][00][19][0B][0A][07][13][10][0B][2B][0C][0C][2C][B1][21][10][0B][07][1D][03][12][57][19][1C][03][02][21][14][4E]";

            byte[]            buf    = GetBuffer(msg);
            UdpFreeformEntity buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity   ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            //var ff2 = new FreeformHandlerFactory();
            //ff2.ProcessMessage(ff as FFMsg_G2H);
            //IMonitorEntity_Msg mon = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
Beispiel #10
0
        static void TestEncryptedTicketMessage()
        {
            string msg =
                "[C0][A8][02][12][05][A2][BC][8A][0A][00][01][00][01][00][37][8B][1A][02][0C][C4][45][63][27][29][35][AB][DC][44][3D][8E][7B][79][C0][49][86][DB][4C][66][38][22][25][DD][DC][06][0C][01][80][00][00][00][00][00][00][00][00][00][00][10][0B][07][1D][03][15][10][50][1C][03][08][21][13][A9]";

            byte[]            buf    = GetBuffer(msg);
            UdpFreeformEntity buffer = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buf);
            IFreeformEntity   ff     = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, buffer);
            //var ff2 = new FreeformHandlerFactory();
            //ff2.ProcessMessage(ff as FFMsg_G2H);
            //IMonitorEntity_Msg mon = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);
        }
        public void MeterTestMethod()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][12][05][A2][B9][0F][59][00][01][00][01][01][5B][10][2A][01][79][00][00][00][00][00][0B][18][00][00][00][00][00][00][00][00][00][00][00][00][00][20][30][30][30][00][30][30][30][30][00][00][00][01][30][30][30][00][00][00][00][0F][49][02][01][04][00][00][31][15][02][04][00][50][20][55][03][04][00][09][40][35][04][04][00][00][00][00][05][04][00][00][00][00][06][04][00][00][00][00][29][04][00][01][51][21][2A][04][00][00][05][42][2B][04][00][00][00][00][2C][04][00][00][00][00][30][04][00][00][00][00][31][04][00][00][00][00][0F][3D][02][07][04][00][00][00][01][08][04][00][00][00][01][09][04][00][00][00][01][0A][04][00][00][00][00][0B][04][00][00][00][01][0C][04][00][00][00][00][2E][04][00][00][00][00][2F][04][00][00][00][00][0D][04][00][00][00][00][0E][04][00][00][66][00][0F][3F][02][13][05][00][00][00][85][21][14][05][00][00][15][07][82][15][05][00][00][00][00][00][16][05][00][00][00][00][00][17][04][00][00][00][03][18][04][00][00][00][52][19][04][00][00][00][00][1A][04][00][00][00][00][24][00][25][00][28][04][01][52][51][01][0F][32][02][0F][04][00][00][00][00][10][04][00][00][00][00][11][04][00][00][00][00][12][04][00][00][00][00][1F][04][00][00][00][00][20][04][00][00][00][00][26][05][00][00][00][00][00][27][04][00][00][00][00][0F][21][02][1B][04][01][19][65][00][1C][04][01][37][43][19][1D][04][00][00][00][00][1E][04][00][00][00][00][28][04][01][52][51][01][2D][00][10][0B][07][1D][03][08][22][28][1C][03][02][21][14][C8]");
            Assert.IsNotNull(buffer);
            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buffer);

            Assert.IsNotNull(udp);
            IFreeformEntity ff = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);

            Assert.IsNotNull(ff);
            byte[] buffer2 = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, ff);
        }
        public void GIMTest()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][A2][BC][17][B1][00][01][00][01][00][5E][17][5C][01][5A][01][05][30][30][30][30][32][02][05][31][32][33][34][35][03][02][42][39][04][0C][30][30][30][30][30][30][30][31][32][33][34][35][05][06][00][16][80][01][47][4D][06][03][36][30][31][07][2B][4F][63][74][20][31][38][20][32][30][31][33][20][31][35][3A][35][32][3A][31][37][20][56][65][72][2D][33][30][30][2E][30][35][2E][31][34][61][20][4F][70][74][69][6F][6E][73][C4]");
            Assert.IsNotNull(buffer);
            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buffer);

            Assert.IsNotNull(udp);
            IFreeformEntity ff = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);

            Assert.IsNotNull(ff);
            byte[] buffer2 = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, ff);
        }
        public bool Send(UdpFreeformEntity udpEntity)
        {
            using (ILogMethod method = Log.LogMethod(LOGGER, this.DYN_MODULE_NAME, "Send"))
            {
                bool result = default(bool);

                try
                {
                    if (udpEntity == null)
                    {
                        method.Info("Unable to send message (request is empty).");
                        return(false);
                    }

                    byte[] rawData = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.H2G, udpEntity);
                    if (rawData == null ||
                        rawData.Length == 0)
                    {
                        method.Info("Unable to send message (rawData was null or zero length).");
                        return(false);
                    }

                    if (_configStore.LogRawFreeformMessages)
                    {
                        udpEntity.ProcessDate = DateTime.Now;
                        string udpEntityString = udpEntity.ToStringRaw(FF_FlowDirection.H2G);
                        Log.Info(udpEntityString);
                        LOGGER.WriteLogInfo(udpEntityString + Environment.NewLine);
                        LOGGER_UDP_SEND.WriteLogInfo(udpEntity.ProcessDate.ToStringSafe());
                        LOGGER_UDP_SEND.WriteLogInfo(udpEntityString + Environment.NewLine);
                    }

                    using (UdpSocketSendData sendData = new UdpSocketSendData()
                    {
                        IPAddress = udpEntity.Address,
                        PortNo = _configStore.TransmitPortNo,
                        Buffer = rawData,
                    })
                    {
                        result = _sockTransmitter.Transmit(sendData);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
Beispiel #14
0
        public void Entity_WithdrawalRequest()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][A2][BC][0E][01][00][01][00][01][00][0F]" +
                                                 "[0E][0D][01][03][00][00][25][20][10][00][50][00][26][06][52][3B]");
            Assert.IsNotNull(buffer);
            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buffer);

            Assert.IsNotNull(udp);
            IFreeformEntity ff = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);

            Assert.IsNotNull(ff);
            byte[] buffer2 = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, ff);
            string sBuffer = buffer2.GetConvertBytesToHexString(string.Empty);
        }
Beispiel #15
0
        public bool Send(UdpFreeformEntity request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "Send"))
            {
                bool result = default(bool);

                try
                {
                    if (request == null)
                    {
                        method.Info("Unable to send message (request is empty).");
                        return(false);
                    }

                    byte[] rawData = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, request);
                    if (rawData == null ||
                        rawData.Length == 0)
                    {
                        method.Info("Unable to send message (rawData was null or zero length).");
                        return(false);
                    }

                    using (UdpSocketSendData sendData = new UdpSocketSendData()
                    {
                        IPAddress = Extensions.GetIpAddress(-1),
                        PortNo = _configStore.ReceivePortNo,
                        Buffer = rawData,
                    })
                    {
                        result = _sockTransmitter.Transmit(sendData);

                        if (this.AfterSendUdpEntityData != null)
                        {
                            byte[] rawDataWithoutIp = new byte[rawData.Length - 4];
                            Buffer.BlockCopy(rawData, 4, rawDataWithoutIp, 0, rawDataWithoutIp.Length);
                            request.RawData     = rawDataWithoutIp;
                            request.ProcessDate = DateTime.Now;
                            this.AfterSendUdpEntityData(request);
                        }
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }
 protected void RaiseReceiveEvent(UdpFreeformEntity udp)
 {
     using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "RaiseReceiveEvent"))
     {
         try
         {
             if (this.Receive != null)
             {
                 this.Receive(udp);
             }
         }
         catch (Exception ex)
         {
             method.Exception(ex);
         }
     }
 }
Beispiel #17
0
        public bool Send(UdpFreeformEntity entity)
        {
            bool result = false;

            try
            {
                byte[] buffer = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, entity.EntityData);
                _udpClient.Send(buffer, buffer.Length);
                result = true;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return(result);
        }
Beispiel #18
0
        private void OnReceiveUdpEntityFromSocket(UdpSocketReceiveData message)
        {
            using (ILogMethod method = Log.LogMethod("", "OnReceiveUdpEntityFromSocket"))
            {
                try
                {
                    // create the raw entity message
                    string ipAddress = ((System.Net.IPEndPoint)message.RemoteEndpoint).Address.ToStringSafe();
                    method.InfoV("RECV_SOCK : Received from {0} / {1:D}",
                                 ipAddress, message.BufferLength);
                    UdpFreeformEntity udpEntity = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.H2G, message.Buffer, ipAddress);
                    if (udpEntity == null ||
                        udpEntity.RawData == null ||
                        udpEntity.RawData.Length == 0)
                    {
                        method.Info("RECV_SOCK : Unable to parse the data from socket (Invalida message format).");
                        return;
                    }

                    // convert the freeform entity message
                    IFreeformEntity ffEntity = FreeformEntityFactory.CreateEntity(FF_FlowDirection.H2G, udpEntity);
                    if (ffEntity == null)
                    {
                        method.Info("RECV_SOCK : Unable to create the freeform entity from udp entity message.");
                        return;
                    }

                    // process the message
                    udpEntity.EntityData = ffEntity;
                    method.InfoV("RECV_SOCK (Success) : {0} [{1}] was received for processing.",
                                 udpEntity, udpEntity.ProcessDate.ToStringSafe());

                    if (this.ReceiveUdpEntityData != null)
                    {
                        this.ReceiveUdpEntityData(udpEntity);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
            }
        }
        public void Buffer_TicketRedeem_End_H2G()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][FB][8A][01][00][01][00][01][00][04][0A][02][04][00][5F]");
            Assert.IsNotNull(buffer);

            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.H2G, buffer);

            Assert.IsNotNull(udp);

            string          sBuffer1 = udp.RawData.GetConvertBytesToHexString(string.Empty);
            IFreeformEntity ff       = FreeformEntityFactory.CreateEntity(FF_FlowDirection.H2G, udp);

            Assert.IsNotNull(ff);

            byte[] buffer2  = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.H2G, ff);
            string sBuffer2 = buffer2.GetConvertBytesToHexString(string.Empty);

            Assert.AreEqual(sBuffer1, sBuffer2);
        }
        public void FF2Buf_GIM_GameIDInfo_H2G()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][FB][17][01][00][01][00][01][00][1C][17][1A][02][09][01][53][75][63][63][65][73][73][21][03][04][0A][02][1E][68][04][04][00][01][23][45][05][01][47][3C]");
            Assert.IsNotNull(buffer);

            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.H2G, buffer);

            Assert.IsNotNull(udp);

            string          sBuffer1 = udp.RawData.GetConvertBytesToHexString(string.Empty);
            IFreeformEntity ff       = FreeformEntityFactory.CreateEntity(FF_FlowDirection.H2G, udp);

            Assert.IsNotNull(ff);

            byte[] buffer2  = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.H2G, ff);
            string sBuffer2 = buffer2.GetConvertBytesToHexString(string.Empty);

            Assert.AreEqual(sBuffer1, sBuffer2);
        }
        public void Buffer_TicketVoid_G2H()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][A2][BC][8A][01][00][01][00][01][00][0D]" +
                                                 "[0A][0B][02][10][00][00][00][00][78][78][90][98][01][C3]");
            Assert.IsNotNull(buffer);

            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buffer);

            Assert.IsNotNull(udp);

            string          sBuffer1 = udp.RawData.GetConvertBytesToHexString(string.Empty);
            IFreeformEntity ff       = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);

            Assert.IsNotNull(ff);

            byte[] buffer2  = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, ff);
            string sBuffer2 = buffer2.GetConvertBytesToHexString(string.Empty);

            Assert.AreEqual(sBuffer1, sBuffer2);
        }
Beispiel #22
0
        private void OnListenReceiveFromSocket()
        {
            try
            {
                int              waitTime       = 100; // 100 milliseconds
                IPEndPoint       remoteEndPoint = null;
                IExecutorService exec           = this.ExecutorService;
                while (!exec.WaitForShutdown(100)) // Invokes after every  10 secs
                {
                    // rangesh starts here
                    try
                    {
                        IAsyncResult ahReceive = _udpClient.BeginReceive(null, null);
                        int          idx       = exec.WaitAny(ahReceive.AsyncWaitHandle, -1);
                        if (idx == 0)
                        {
                            break;
                        }

                        byte[] rawData = _udpClient.EndReceive(ahReceive, ref remoteEndPoint);
                        if (rawData != null && rawData.Length > 0)
                        {
                            UdpFreeformEntity udp            = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, rawData);
                            IFreeformEntity   freeformEntity = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);
                            udp.EntityData = freeformEntity;
                            this.OnReceiveFromSocket(udp);
                        }
                    }
                    catch (Exception e)
                    {
                        ExceptionManager.Publish(e);
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionManager.Publish(e);
            }
        }
        public void FF2Mon_GIM_GameIDInfo_G2H()
        {
            byte[] buffer = TestHelper.GetBuffer("[C0][A8][02][10][05][A2][BC][17][B1][00][01][00][01][00][5E][17][5C][01][5A][01][05][30][30][30][30][32][02][05][31][32][33][34][35][03][02][42][39][04][0C][30][30][30][30][30][30][30][31][32][33][34][35][05][06][00][16][80][01][47][4D][06][03][36][30][31][07][2B][4F][63][74][20][31][38][20][32][30][31][33][20][31][35][3A][35][32][3A][31][37][20][56][65][72][2D][33][30][30][2E][30][35][2E][31][34][61][20][4F][70][74][69][6F][6E][73][C4]");
            Assert.IsNotNull(buffer);

            UdpFreeformEntity udp = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, buffer);

            Assert.IsNotNull(udp);

            string          sBuffer1 = buffer.GetConvertBytesToHexString(string.Empty);
            IFreeformEntity ff       = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udp);

            Assert.IsNotNull(ff);

            byte[] buffer2  = FreeformEntityFactory.CreateBuffer(FF_FlowDirection.G2H, ff);
            string sBuffer2 = buffer2.GetConvertBytesToHexString(string.Empty);

            Assert.AreEqual(sBuffer1, sBuffer2);

            IMonitorEntity monitor = MonitorEntityFactory.CreateEntity(ff as FFMsg_G2H);

            Assert.IsNotNull(monitor);
        }
Beispiel #24
0
 protected abstract void OnReceiveFromSocket(UdpFreeformEntity udp);
 protected override void OnReceiveFromSocket(UdpFreeformEntity udp)
 {
     // put it into sqlite db
 }
 public static void AddReceiverToQueue(UdpFreeformEntity udpFreeformEntity)
 {
     BlockingCollection <UdpFreeformEntity>
     itemUdpFreeformEntities.Enqueue(udpFreeformEntity);
 }
Beispiel #27
0
 protected override void OnReceiveFromSocket(UdpFreeformEntity udp)
 {
     _queue.Enqueue(udp);
 }
        private void OnReceiveUdpEntityFromSocket(UdpSocketReceiveData message)
        {
            using (ILogMethod method = Log.LogMethod(LOGGER, this.DYN_MODULE_NAME, "OnReceiveUdpEntityFromSocket"))
            {
                try
                {
                    // create the raw entity message
                    method.InfoV("RECV_SOCK : Received from {0} / {1:D}",
                                 message.RemoteEndpoint.ToString(), message.BufferLength);
                    UdpFreeformEntity udpEntity = FreeformEntityFactory.CreateUdpEntity(FF_FlowDirection.G2H, message.Buffer);
                    if (udpEntity == null ||
                        udpEntity.RawData == null ||
                        udpEntity.RawData.Length == 0)
                    {
                        method.Info("RECV_SOCK : Unable to parse the data from socket (Invalida message format).");
                        if (udpEntity != null &&
                            udpEntity.Address != null)
                        {
                            // send the nack
                            this.Send(FreeformEntityFactory.CreateH2GMessageAckNack(udpEntity.AddressString, true));
                        }
                        return;
                    }

                    // convert the freeform entity message
                    FFMsg_G2H g2hMessage = FreeformEntityFactory.CreateEntity(FF_FlowDirection.G2H, udpEntity) as FFMsg_G2H;
                    if (g2hMessage == null)
                    {
                        method.Info("RECV_SOCK : Unable to create the freeform entity from udp entity message.");
                        // send the nack
                        this.Send(FreeformEntityFactory.CreateH2GMessageAckNack(udpEntity.AddressString, true));
                        return;
                    }

                    // send the ack message (if necessary)
                    FFMsg_H2G msgAck = FreeformEntityFactory.CreateH2GMessageAckNack(udpEntity.AddressString, g2hMessage.Command);
                    if (msgAck != null)
                    {
                        this.Send(msgAck);
                    }

                    // process the message
                    udpEntity.EntityData = g2hMessage;
                    method.InfoV("RECV_SOCK (Success) : {0} [{1}] was received for processing.",
                                 udpEntity, udpEntity.ProcessDate.ToStringSafe());
                    if (_configStore.LogRawFreeformMessages)
                    {
                        string udpEntityString = udpEntity.ToStringRaw(FF_FlowDirection.G2H);
                        Log.Info(udpEntityString);
                        LOGGER.WriteLogInfo(udpEntityString + Environment.NewLine);
                        LOGGER_UDP_RECV.WriteLogInfo(udpEntity.ProcessDate.ToStringSafe());
                        LOGGER_UDP_RECV.WriteLogInfo(udpEntityString + Environment.NewLine);
                    }
                    this.OnReceiveFromSocket(udpEntity);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
            }
        }