Esempio n. 1
0
        void HandleInvalidViewerPassword(RCS_Protocol.RCS_Protocol.PACKET_HEADER header, byte[] payload)
        {
            m_Log.Log("HandleInvalidViewerPassword", ErrorLog.LOG_TYPE.INFORMATIONAL);

            string message = ExtractMessage(payload);
            if (MessageEventGenerators.OnRxInvalidPassword != null) MessageEventGenerators.OnRxInvalidPassword(message);
        }
Esempio n. 2
0
        void HandleReceiveChannelList(RCS_Protocol.RCS_Protocol.PACKET_HEADER header, byte[] payload)
        {
            if (payload == null) return;
            if (header == null) return;

            try
            {
                List<string> nameslist = new List<string>();

                int offset = 0;
                for (int i = 0; i < payload.Length; i++)
                {
                    if (payload[i] == 0)
                    {
                        string s = System.Text.ASCIIEncoding.ASCII.GetString(payload, offset, i - offset);
                        offset = i + 1;
                        nameslist.Add(s);
                    }
                }
                string[] list = nameslist.ToArray();

                if (MessageEventGenerators.OnRxChannelList != null) MessageEventGenerators.OnRxChannelList(list);

            }
            catch (Exception ex)
            {
                m_Log.Log("HandleReceiveChannelList ex:" + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
            }
        }
Esempio n. 3
0
        //  ///////////////////////////////////////////////////
        //
        //   pull message bodies from the socket and then push to the registered clients.
        //
        void HandleValidViewerPassword(RCS_Protocol.RCS_Protocol.PACKET_HEADER  header, byte [] payload)
        {
            m_Log.Log("HandleValidAdminPassword", ErrorLog.LOG_TYPE.INFORMATIONAL);

            if (MessageEventGenerators.OnRxValidViewerPW != null) MessageEventGenerators.OnRxValidViewerPW();
        }
Esempio n. 4
0
        void HandleReceiveStats(RCS_Protocol.RCS_Protocol.PACKET_HEADER header, byte[] payload)
        {
            string s = System.Text.ASCIIEncoding.ASCII.GetString(payload);
             //APPLICATION_DATA.HEALTH_STATISTICS stats =  m_RCSProtocol.ParseStats(s);
             //if (stats == null) return;

             MessageEventGenerators.OnRxHealthStatus(s);
        }
Esempio n. 5
0
 //  ///////////////////////////////////////////////////
 //
 //   Receive JPEG images
 //
 void HandleReceiveJPeg(RCS_Protocol.RCS_Protocol.PACKET_HEADER header, byte[] payload, string channel, string timeStamp, string plateReading)
 {
     MessageEventGenerators.OnRxJpeg(payload, channel, timeStamp, plateReading);
 }
Esempio n. 6
0
        void HandleReceiveHostName(RCS_Protocol.RCS_Protocol.PACKET_HEADER header, byte[] payload)
        {
            string name = "";
            try
            {
                name = System.Text.ASCIIEncoding.ASCII.GetString(payload);
            }
            catch (Exception ex)
            {
                m_Log.Log("HandleReceiveHostName ex:" + ex.Message, ErrorLog.LOG_TYPE.INFORMATIONAL);
                return;
            }

            if (MessageEventGenerators.OnRxHostName != null) MessageEventGenerators.OnRxHostName(name);
        }
Esempio n. 7
0
        void HandleReceivedMessage(RCS_Protocol.RCS_Protocol.PACKET_TYPES type, byte[] data, ConnectionServer.ClientConnection connection, object packetHeader)
        {
            try
            {
                switch (type)
                {
                    case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_STATS:
                        {
                            // CreatePacket(PACKET_TYPES type, string data)
                            connection.SendHealthStats(m_AppData.HealthStatistics);

                        }
                        break;
                    case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_CHANNEL_LIST:
                        {
                            FrameGenerator fg = (FrameGenerator)m_AppData.FrameGenerator;
                            string[] list = fg.GetChannelList();
                            connection.SendChannelList(list);
                        }
                        break;

                    case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_LIVE_VIEW:
                        {
                            RCS_Protocol.RCS_Protocol.LIVE_VIEW_HEADER jpegHeader = (RCS_Protocol.RCS_Protocol.LIVE_VIEW_HEADER)packetHeader;

                            // parse out the requested channel ID from the info string

                            // int channel = Convert.ToInt32(jpegHeader.cameraName);
                            string timeStamp = null;
                            int channelIndex = 0;
                            string lastPlateReading = null;
                            byte[] jpeg = GetCurrentJpeg(jpegHeader.cameraName, out timeStamp, out lastPlateReading, out channelIndex);
                            if (jpeg == null)
                            {
                                jpeg = new byte[10]; // will be treated as null image on receiving end, but keep the state machine going
                            }
                            connection.SendJpeg(jpeg, jpegHeader.cameraName, timeStamp, lastPlateReading);
                            jpeg = null;
                        }
                        break;

                    case RCS_Protocol.RCS_Protocol.PACKET_TYPES.REQUEST_HOST_NAME:
                        {
                            connection.SendHostName(m_AppData.ThisComputerName);
                        }
                        break;
                }
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }