Beispiel #1
0
 /// <summary>
 /// 注册回调函数,接收设备报警消息等。
 /// </summary>
 /// <param name="index">回调函数索引,取值范围:[0,15] </param>
 /// <param name="alarmCallBack">回调函数委托</param>
 /// <returns>TRUE表示成功,FALSE表示失败。</returns>
 public static bool SetDVRMessageCallBack_V50(int index, MSGCallBack alarmCallBack)
 {
     if (alarmCallBack == null)
     {
         return(false);
     }
     return(HikApi.NET_DVR_SetDVRMessageCallBack_V50(index, alarmCallBack, IntPtr.Zero));
 }
Beispiel #2
0
        /// <summary>
        /// 解析数据
        /// </summary>
        /// <param name="data"></param>
        void ParseReceiveData(byte[] data)
        {
            MSGCallBack ReceiveMsg = ProtoBufDataDeSerialize <MSGCallBack>(data);

            if (ParsedDataObjPacker != null)
            {
                ParsedDataObjPacker(ReceiveMsg.RequestCode, ReceiveMsg.ActionCode, ReceiveMsg.DataList);
            }
        }
Beispiel #3
0
        public static byte[] PackData(ActionCode actionCode, byte[] data)
        {
            MSGCallBack sendData = new MSGCallBack(actionCode, data);

            byte[] dataBytes = ProtoBufDataSerialize(sendData);
            // byte[] actionCodeBytes = BitConverter.GetBytes((int)actionCode);
            //byte[] dataBytes = Encoding.UTF8.GetBytes(data);
            int dataAmount = dataBytes.Length;

            byte[] dataAmountBytes = BitConverter.GetBytes(dataAmount);
            return(dataAmountBytes.Concat(dataBytes).ToArray <byte>());
        }
Beispiel #4
0
        public byte[] GetInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <InventoryInfo> receive = mInv.GetInventoryListInfo(_client.MySQLConn, _client.GetCurAccount.AccountId);

            if (receive.Count > 0)
            {
                return(MessageTool.ProtoBufDataSerialize(receive));
            }
            MSGCallBack send = new MSGCallBack(ReturnCode.Fail);

            return(MessageTool.ProtoBufDataSerialize(send));
        }
Beispiel #5
0
        /// <summary>
        /// 更新人物信息
        /// </summary>
        public byte[] UpdateCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            CharacterInfo receive = MessageTool.ProtoBufDataDeSerialize <CharacterInfo>(_data);
            CharacterInfo info    = mCharacter.UpdateOrAddCharacter(_client.MySQLConn, receive, false);

            MSGCallBack send = null;

            if (info != null)
            {
                send = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                send = new MSGCallBack(ReturnCode.Fail);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }
        public byte[] Login(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);
            AccountInfo user   = mAccount.VerifyUser(client.MySQLConn, recive.AccountName, recive.Password);

            MSGCallBack msg;

            if (user == null)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                client.IsOnLine = true;
                client.SetCurAccountData(user);
                msg = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
        public byte[] Register(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);

            bool        res = mAccount.GetAccountByAccountId(client.MySQLConn, recive.AccountId);
            MSGCallBack msg;

            if (res)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                mAccount.AddAccount(client.MySQLConn, recive.AccountId,
                                    recive.AccountName, recive.Password, 1001, client.ImgPathDic[1001]);
                client.IsOnLine = true;
                msg             = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
Beispiel #8
0
        public byte[] JoinRoom(byte[] _data, ClientPeer _client, MainServer _server)
        {
            RoomInfo    roomInfo = MessageTool.ProtoBufDataDeSerialize <RoomInfo>(_data);
            MSGCallBack sendMsg  = null;

            foreach (var room in _server.RoomList)
            {
                if (roomInfo.RoomId == room.GetRoonInfo.RoomId)
                {
                    if (room.GetRoonInfo.TotalNum >= room.GetRoonInfo.PlayerNum)
                    {
                        _server.JoinRoom(_client, room);
                        sendMsg = new MSGCallBack(ReturnCode.Success);
                    }
                    else
                    {
                        sendMsg = new MSGCallBack(ReturnCode.Fail);
                    }
                }
            }
            return(MessageTool.ProtoBufDataSerialize(sendMsg));
        }
Beispiel #9
0
        public byte[] UpdateInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <InventoryInfo> inv  = MessageTool.ProtoBufDataDeSerialize <List <InventoryInfo> >(_data);
            MSGCallBack          send = null;

            if (!isAdded)
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], true);
                }
                isAdded = true;
                send    = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], false);
                }
                send = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }
Beispiel #10
0
 public static extern int IP_NET_DVR_SetDVRMessageCallBack(MSGCallBack fMessageCallBack, IntPtr pUser);
Beispiel #11
0
 public static extern int NET_DVR_StartListen_V30(string sLocalIP, short wLocalPort, MSGCallBack DataCallback, IntPtr pUserData);
 public static extern bool NET_DVR_SetDVRMessageCallBack_V30(MSGCallBack fMessageCallBack, IntPtr pUser);
Beispiel #13
0
 public static extern bool NET_DVR_SetDVRMessageCallBack_V30(MSGCallBack fMessageCallBack, IntPtr pUser);
Beispiel #14
0
 public static extern int NET_DVR_StartListen_V30(string sLocalIP, short wLocalPort, MSGCallBack DataCallback, IntPtr pUserData);
Beispiel #15
0
 public static extern bool NET_DVR_SetDVRMessageCallBack_V50(int index, MSGCallBack fMessageCallBack, IntPtr pUser);