Ejemplo n.º 1
0
        public void ProcessNewMessage(Message message)
        {
            logger.info("process new message: {0}", message);
            MessageModelDelivered messageModel = new MessageModelDelivered(message);
            Peer targetPeer = messageModel.Peer;

            DialogModel targetDialogModel = null;

            foreach (DialogModel dialogModel in dialogs)
            {
                if (!dialogModel.IsEncrypted && TLStuff.PeerEquals(dialogModel.Peer, targetPeer))
                {
                    targetDialogModel = dialogModel;
                    break;
                }
            }

            if (targetDialogModel == null)
            {
                logger.info("target dialog not found, creating new...");
                targetDialogModel = new DialogModelPlain(messageModel, session);
                dialogs.Insert(0, targetDialogModel);
            }
            else
            {
                logger.info("target dialog found, rearrange...");
                UpDialog(targetDialogModel);
            }

            targetDialogModel.ProcessNewMessage(messageModel);

            if (targetDialogModel == TelegramSession.Instance.Dialogs.OpenedDialog)
            {
                targetDialogModel.OpenedRead();
            }
        }
Ejemplo n.º 2
0
        public void ProcessNewMessage(Message message) {

            logger.info("process new message: {0}", message);
            MessageModelDelivered messageModel = new MessageModelDelivered(message);
            Peer targetPeer = messageModel.Peer;

            DialogModel targetDialogModel = null;

            foreach(DialogModel dialogModel in dialogs) {
                if (!dialogModel.IsEncrypted && TLStuff.PeerEquals(dialogModel.Peer, targetPeer)) {
                    targetDialogModel = dialogModel;
                    break;
                }
            }

            if(targetDialogModel == null) {
                logger.info("target dialog not found, creating new...");
                targetDialogModel = new DialogModelPlain(messageModel, session);
                    dialogs.Insert(0, targetDialogModel);
            } else {
                logger.info("target dialog found, rearrange...");
                UpDialog(targetDialogModel);
            }

            targetDialogModel.ProcessNewMessage(messageModel);

            if(targetDialogModel == TelegramSession.Instance.Dialogs.OpenedDialog) {
                targetDialogModel.OpenedRead();
            }
        }