Exemplo n.º 1
0
        public void HandleMessage(MemoryStream msg, Session session)
        {
            var             addFriend       = ProtobufHelper.FromStream(typeof(AddFriendMessage), msg) as AddFriendMessage;
            AccountDAO      accountDAO      = new AccountDAO();
            var             id              = accountDAO.GetAccountIdByEmail(DBHelper.Instance.GetConnection(), addFriend.FriendEmail);
            FriendDAO       friendDAO       = new FriendDAO();
            ResponseMessage responseMessage = new ResponseMessage();

            if (id != -1)
            {
                var result = friendDAO.InsertFriend(DBHelper.Instance.GetConnection(), addFriend.OwnerId, id);
                if (result)
                {
                    responseMessage.Message = "Y";
                }
                else
                {
                    responseMessage.Message = "N";
                }
            }
            else
            {
                responseMessage.Message = "N";
            }
            ResponseMessage(responseMessage, session);
        }
Exemplo n.º 2
0
        public void HandleMessage(MemoryStream msg, Session session)
        {
            var               msgs       = ProtobufHelper.FromStream(typeof(FriendListMessage), msg) as FriendListMessage;
            var               conn       = DBHelper.Instance.GetConnection();
            FriendDAO         fDao       = new FriendDAO();
            var               friendList = fDao.GetFriendIdList(conn, msgs.OwnerId);
            AccountDAO        accountDAO = new AccountDAO();
            FriendListMessage message    = new FriendListMessage();

            foreach (var i in friendList)
            {
                var         connT     = DBHelper.Instance.GetConnection();
                var         friend    = accountDAO.GetAccountById(connT, i);
                Core.Friend friendObj = new Core.Friend()
                {
                    UserName = friend.UserName,
                    Phone    = friend.Phone,
                    Email    = friend.Email
                };
                message.Friends.Add(friendObj);
            }

            ResponseMessage(message, session);
        }