Пример #1
0
        private void fireOnRealtimeInfo(VideoParser.Camera camera, VideoParser.GPS gps)
        {
            OnRealtimeInfo callback = _realtimeInfoEvent;

            if (callback != null)
            {
                callback(camera, gps);
            }
        }
Пример #2
0
        private void onMessage(byte[] message)
        {
            MessageReader reader = new MessageReader(message);

            MessageReader.StreamReader stream = reader.Reader;
            switch (reader.MessageID)
            {
            case 0x11017:     // Msg_NetCtrl_Nodebase_Name
                _serverName = stream.ReadString();
                break;

            case 0x11013:     // Msg_NetCtrl_User_Params
            {
                string user  = stream.ReadString();
                bool   valid = stream.ReadInt32() != 0;
                if (valid)
                {
                    if (!Ready)
                    {
                        _userStage  = stream.ReadInt32();
                        _userRights = stream.ReadInt32();
                        _serverID   = stream.ReadUInt64();
                        int len = stream.ReadInt32();
                        _userAuth = new ulong[len];
                        for (int i = 0; i < len; i++)
                        {
                            _userAuth[i] = stream.ReadUInt64();
                        }
                        Ready = true;
                        fireOnAuthentication(true);

                        sendGetRealtimeMessage();
                    }
                }
                else
                {
                    Ready = false;
                    cancelLoginChecker();
                    fireOnAuthentication(false);
                    _connection.Reconnect();
                }
            }
            break;

            case 0x11015:     // Msg_NetCtrl_ID
                _netctrlID = stream.ReadInt32();
                break;

            case 0x10030:     // Msg_Tree_Info
                break;

            case 0x10032:     // Msg_Xml_Tree
            {
                bool   up           = stream.ReadInt32() != 0;
                int    size         = stream.ReadInt32();
                int    uncompSize   = stream.ReadInt32();
                byte[] compressed   = stream.ReadBytes(size - sizeof(Int32));
                byte[] uncompressed = ZLibUtil.Uncompress(compressed, uncompSize);
                string xml          = Encoding.Default.GetString(uncompressed);
                if (xml.Last() == 0)
                {
                    xml = xml.Substring(0, xml.Length - 1);
                }

                VideoParser.Node tree = null;
                if (xml != _lastBaseXml && VideoParser.TryParseNode(xml, out tree))
                {
                    fireOnNodeTree(tree, xml);
                    _lastBaseXml = xml;
                    updateTree(tree);
                }
            }
            break;

            case 0x11021:     // Msg_Video_Port
            {
                ulong videoID   = stream.ReadUInt64();
                int   oldPort   = stream.ReadInt32();
                int   bandwidth = stream.ReadInt32();
                int   port      = stream.ReadInt32();
                fireOnVideoPort(videoID, port, bandwidth);
            }
            break;

            case 0x11022:     // Msg_Video_Miss
            {
                ulong videoID = stream.ReadUInt64();
                fireOnVideoMiss(videoID);
            }
            break;

            case 0x100B1:     //Msg_Realtime_Info
            {
                string             xml    = stream.ReadString();
                VideoParser.Camera camera = null;
                VideoParser.GPS    gps    = null;
                if (VideoParser.TryParseRealtime(xml, out camera) || VideoParser.TryParseRealtime(xml, out gps))
                {
                    fireOnRealtimeInfo(camera, gps);
                }
            }
            break;

            case 0x11028:     // Msg_Video_Ctrl
            {
                ulong videoId = stream.ReadUInt64();
                int   msgId   = stream.ReadInt32();
                onFeedbackMessage(videoId, msgId, reader);
            }
            break;
            }
        }