示例#1
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); }
        }