Ejemplo n.º 1
0
        void MessageProgressCallback.rejected(string reason)
        {
            OutgoingMessage message = (OutgoingMessage)this;

            lock (message)
            {
                if (state == MessageState.POSTED ||
                    state == MessageState.TRANSMITTED)
                {
                    MessageState previousState = state;

                    state           = MessageState.REJECTED;
                    rejectionReason = reason;

                    if (previousState == MessageState.POSTED)
                    {
                        transmitted = true;
                    }

                    completed = true;
                    Monitor.PulseAll(message);
                }
            }

            message.updateUserCallback();
        }
Ejemplo n.º 2
0
 internal static void VaidateMessageState(IEnumerable <Message> messages, MessageState expectedState)
 {
     if (messages.Any(m => m.SystemProperties.State != expectedState))
     {
         throw new Exception($"At least one message has state that is not {expectedState}");
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 输出消息
        /// </summary>
        /// <param name="state"></param>
        void writeMessage(MessageState state)
        {
            if (state == null)
            {
                return;
            }

            if (state.PadTime)
            {
                state.Text += DateTime.Now.ToString(" --yyyy-MM-dd HH:mm:ss");
            }

            lock (writeLocker)
            {
                int lines = this.rtxtMsg.Lines.Length;

                if (lines > 50)
                {
                    var newLines = this.rtxtMsg.Lines.ToList();
                    newLines.RemoveRange(0, lines - 50);
                    this.rtxtMsg.Lines = newLines.ToArray();
                }
                this.rtxtMsg.AppendText("\n");
                this.rtxtMsg.SelectionColor = state.Color;
                this.rtxtMsg.AppendText(state.Text);

                this.rtxtMsg.Focus();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the state of the message.
 /// </summary>
 /// <param name="mid">The mid.</param>
 /// <param name="state">The state.</param>
 public void SetMessageState(MessageManagerId mid, MessageState state)
 {
     lock (_messageQueue)
     {
         _messageStates[mid.GetHashCode()] = state;
     }
 }
Ejemplo n.º 5
0
 private void RaiseOnOnDialogPopupComplete(MessageState state)
 {
     if (onDialogPopupComplete != null)
     {
         onDialogPopupComplete(state);
     }
 }
Ejemplo n.º 6
0
        protected override async Task SendMessageStateAsync(MessageState messageState, CancellationToken cancellationToken)
        {
            var messageContext = messageState.MessageContext;
            await _messageQueueClient.PublishAsync(messageContext, messageContext.Topic ?? _defaultTopic, cancellationToken);

            CompleteSendingMessage(messageState);
        }
Ejemplo n.º 7
0
        void MessageProgressCallback.replied(Parameters body, byte[] rawBody)
        {
            OutgoingMessage message = (OutgoingMessage)this;

            lock (message)
            {
                if (state == MessageState.POSTED ||
                    state == MessageState.TRANSMITTED)
                {
                    MessageState previousState = state;

                    state    = MessageState.REPLIED;
                    reply    = body;
                    rawReply = rawBody;

                    if (previousState == MessageState.POSTED)
                    {
                        transmitted = true;
                    }

                    completed = true;
                    Monitor.PulseAll(message);
                }
            }

            message.updateUserCallback();
        }
        public void ToString_ReturnsJson()
        {
            const string        requestId = "a";
            const MessageMethod method    = MessageMethod.GetOperationClaims;
            const MessageType   type      = MessageType.Request;
            const MessageState  state     = MessageState.Sent;

            var now = DateTimeOffset.UtcNow;

            var logMessage = new CommunicationLogMessage(now, requestId, method, type, state);

            var message = VerifyOuterMessageAndReturnInnerMessage(logMessage, now, "communication");

            Assert.Equal(4, message.Count);

            var actualRequestId = message.Value <string>("request ID");
            var actualMethod    = Enum.Parse(typeof(MessageMethod), message.Value <string>("method"));
            var actualType      = Enum.Parse(typeof(MessageType), message.Value <string>("type"));
            var actualState     = Enum.Parse(typeof(MessageState), message.Value <string>("state"));

            Assert.Equal(requestId, actualRequestId);
            Assert.Equal(method, actualMethod);
            Assert.Equal(type, actualType);
            Assert.Equal(state, actualState);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据状态取得短消息分页列表
        /// </summary>
        /// <param name="state"></param>
        /// <param name="senderID"></param>
        /// <param name="receiverID"></param>
        /// <param name="from"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <ShortMessage> GetPagedMessages(MessageState state, string senderID, string receiverID, int from, int count)
        {
            Criteria c = CreateCriteriaFromState(state, senderID, receiverID);

            Order[] o = new Order[] { new Order("Created", OrderMode.Desc) };
            return(Assistant.List <ShortMessage>(c, o, from, count));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Sets the temporary data message and state
        /// </summary>
        /// <param name="tempData">Temporary data dictionary to use</param>
        /// <param name="state">State to set</param>
        /// <param name="message">Message to set</param>
        public static void SetTemporaryMessage(ITempDataDictionary tempData, MessageState state, string message)
        {
            if (tempData == null)
            {
                throw new ArgumentNullException(nameof(tempData));
            }

            if (tempData.ContainsKey("MessageState"))
            {
                tempData["MessageState"] = state;
            }
            else
            {
                tempData.Add("MessageState", state);
            }

            if (tempData.ContainsKey("Message"))
            {
                tempData["Message"] = message;
            }
            else
            {
                tempData.Add("Message", message);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Returns all chat messages for the given userAccountId and state ordered by their chatId.
 /// </summary>
 public IList <ChatMessageTable> getChatMessages(string userAccountId, MessageState state)
 {
     return(dB.Query <ChatMessageTable>(true, "SELECT m.* "
                                        + "FROM " + DBTableConsts.CHAT_MESSAGE_TABLE + " m JOIN " + DBTableConsts.CHAT_TABLE + " c ON m.chatId = c.id "
                                        + "WHERE c.userAccountId = ? AND m.state = ?"
                                        + "ORDER BY m.chatId ASC;", userAccountId, state));
 }
Ejemplo n.º 12
0
        public static TransStream DoResponse(IQueueItem item, MessageState state)
        {
            if (item == null)
            {
                return(null);
                //throw new MessageException(MessageState.MessageError, "Invalid queue item to write response");
            }

            var ts = ((QueueItem)item).ToTransStream(state);

            //((QueueItem)item).SetState(state);
            QLogger.Debug("QueueController DoResponse IQueueAck: {0}", item.Print());
            //return item.ToStream();

            return(ts);

            //if (item != null)
            //{
            //    ((QueueItem)item).SetState(state);
            //    return item.GetItemStream();
            //}
            //else
            //{
            //    Message response = Message.Ack(MessageState.UnExpectedError, new MessageException(MessageState.UnExpectedError, "WriteResponse error: there is no item stream to write reponse"));
            //    return response.ToStream();
            //}

            // QLogger.DebugFormat("Server WriteResponse State:{0}, MessageId: {1}", item.MessageState, item.MessageId);
        }
Ejemplo n.º 13
0
        protected MessageState BuildCommandState(IMessageContext commandContext, CancellationToken sendCancellationToken, TimeSpan timeout, CancellationToken replyCancellationToken, bool needReply)
        {
            var sendTaskCompletionSource = new TaskCompletionSource <MessageResponse>();

            if (timeout != TimerTaskFactory.Infinite)
            {
                var timeoutCancellationTokenSource = new CancellationTokenSource(timeout);
                timeoutCancellationTokenSource.Token.Register(OnSendTimeout, sendTaskCompletionSource);
            }

            if (sendCancellationToken != CancellationToken.None)
            {
                sendCancellationToken.Register(OnSendCancel, sendTaskCompletionSource);
            }

            TaskCompletionSource <object> replyTaskCompletionSource = null;
            MessageState commandState = null;

            if (needReply)
            {
                replyTaskCompletionSource = new TaskCompletionSource <object>();
                commandState = new MessageState(commandContext, sendTaskCompletionSource, replyTaskCompletionSource, needReply);
                if (replyCancellationToken != CancellationToken.None)
                {
                    replyCancellationToken.Register(OnReplyCancel, commandState);
                }
            }
            else
            {
                commandState = new MessageState(commandContext, sendTaskCompletionSource, needReply);
            }
            return(commandState);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// 构造器
 /// </summary>
 public MessageJSON(MessageState state, string message, MessageIcon?icon = null, object data = null)
 {
     this.State   = state;
     this.Message = message;
     this.Data    = data;
     this.Icon    = icon;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Mark a message as read adding new MessageState or update existing setting its parameter IsRead to true.
        /// </summary>
        /// <param name="message">Message object.</param>
        /// <param name="member">Member object.</param>
        public void SetAsRead(Message message, ConversationMember member)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            var ms =
                _messageStateRepository.Query().SingleOrDefault(x => x.Member == member && x.Message == message);

            if (ms == null)
            {
                ms = new MessageState
                {
                    IsRead   = true,
                    Member   = member,
                    Message  = message,
                    ReadDate = DateTime.Now
                };
            }
            else
            {
                ms.IsRead   = true;
                ms.ReadDate = DateTime.Now;
            }
            _messageStateRepository.Save(ms);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 访问外部
        /// </summary>
        /// <param name="service">服务名称,用于查找HttpClient,不会与api拼接</param>
        /// <param name="api">完整的接口名称</param>
        /// <param name="forms">Form内容</param>
        /// <returns></returns>
        public static async Task <(MessageState state, string res)> OutFormPost(string service, string api, Dictionary <string, string> forms)
        {
            using var _ = FlowTracer.DebugStepScope("[HttpPoster.OutFormPost]");
            try
            {
                var client = HttpClientOption.HttpClientFactory.CreateClient(service);
                FlowTracer.MonitorDetails(() => $"URL : {client.BaseAddress}{api}");
                using var form     = new FormUrlEncodedContent(forms);
                using var response = await client.PostAsync(api, form);

                var json = await response.Content.ReadAsStringAsync();

                MessageState state = HttpCodeToMessageState(response.StatusCode);

                FlowTracer.MonitorDetails(() => $"HttpStatus : {response.StatusCode} MessageState : {state} Result : {json}");

                return(state, json);
            }
            catch (HttpRequestException ex)
            {
                FlowTracer.MonitorError(() => $"发生异常.{ex.Message}");
                return(MessageState.Unsend, null);
            }
            catch (Exception ex)
            {
                FlowTracer.MonitorError(() => $"发生异常.{ex.Message}");
                return(MessageState.NetworkError, null);
            }
        }
Ejemplo n.º 17
0
 public static MessageState GetMessagesSuccess(MessageState state, GetMessagesSuccessAction action)
 {
     return(state with
     {
         ClientMessages = action.ClientMessages
     });
 }
Ejemplo n.º 18
0
        public void UpdateSendResult(int tenantId, int id, string messageId, MessageState state, string result)
        {
            ArgumentHelper.AssertIsTrue(tenantId > 0, "tenantId is 0");
            ArgumentHelper.AssertIsTrue(id > 0, "id is 0");

            MessageDao.UpdateSendResult(tenantId, id, messageId, state, result);
        }
Ejemplo n.º 19
0
 public static MessageState MessageFailed(MessageState state, MessageFailedAction action)
 {
     return(state with
     {
         ClientMessages = state.ClientMessages
     });
 }
Ejemplo n.º 20
0
 // Running on the UI thread
 private void SetStatus(string text, MessageState state = MessageState.OK)
 {
     Invoke((MethodInvoker) delegate {
         ToolStripStatusLabel.Text      = text;
         ToolStripStatusLabel.ForeColor = GetColor(state);
     });
 }
Ejemplo n.º 21
0
 public static MessageState SendMessage(MessageState state, SendMessageAction action)
 {
     return(state with
     {
         ClientMessages = state.ClientMessages
     });
 }
Ejemplo n.º 22
0
 private void RaiseOnOnRateUSPopupComplete(MessageState state)
 {
     if (AndroidRateUsPopUp.onRateUSPopupComplete != null)
     {
         AndroidRateUsPopUp.onRateUSPopupComplete(state);
     }
 }
Ejemplo n.º 23
0
 public static MessageState GetMessages(MessageState state, GetMessagesAction action)
 {
     return(state with
     {
         ClientMessages = state.ClientMessages
     });
 }
Ejemplo n.º 24
0
 private void RaiseOnOnRateUSPopupComplete(MessageState state)
 {
     if (onRateUSPopupComplete != null)
     {
         onRateUSPopupComplete(state);
     }
 }
Ejemplo n.º 25
0
        public XmlDictionaryReader GetReaderAtBodyContents()
        {
            switch (this.state)
            {
            case MessageState.Created:
                this.state = MessageState.Read;
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceVerbose)
                {
                    TraceUtility.TraceEvent(TraceEventType.Verbose, 0x80013, System.ServiceModel.SR.GetString("TraceCodeMessageRead"), this);
                }
                if (this.IsEmpty)
                {
                    throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageIsEmpty")), this);
                }
                return(this.OnGetReaderAtBodyContents());

            case MessageState.Read:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenRead")), this);

            case MessageState.Written:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenWritten")), this);

            case MessageState.Copied:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenCopied")), this);

            case MessageState.Closed:
                throw TraceUtility.ThrowHelperError(this.CreateMessageDisposedException(), this);
            }
            throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("InvalidMessageState")), this);
        }
Ejemplo n.º 26
0
        void Fill(MessageState messageState, string content)
        {
            try
            {
                switch (messageState)
                {
                case MessageState.Unread:

                    messageIconState.sprite = closedMessageSprite;

                    break;

                case MessageState.Read:

                    messageIconState.sprite = openedMessageSprite;

                    break;
                }

                messageSummaryText.text = content;
            }

            catch (Exception ex)
            {
                Debug.LogWarning("Message init error: " + ex);
            }
        }
Ejemplo n.º 27
0
        public MessageBuffer CreateBufferedCopy(int maxBufferSize)
        {
            if (maxBufferSize < 0)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxBufferSize", maxBufferSize, System.ServiceModel.SR.GetString("ValueMustBeNonNegative")), this);
            }
            switch (this.state)
            {
            case MessageState.Created:
                this.state = MessageState.Copied;
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceVerbose)
                {
                    TraceUtility.TraceEvent(TraceEventType.Verbose, 0x80012, System.ServiceModel.SR.GetString("TraceCodeMessageCopied"), this, this);
                }
                return(this.OnCreateBufferedCopy(maxBufferSize));

            case MessageState.Read:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenRead")), this);

            case MessageState.Written:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenWritten")), this);

            case MessageState.Copied:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenCopied")), this);

            case MessageState.Closed:
                throw TraceUtility.ThrowHelperError(this.CreateMessageDisposedException(), this);
            }
            throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("InvalidMessageState")), this);
        }
Ejemplo n.º 28
0
        protected internal override void Parse(ImapResponseReader reader)
        {
            while (true) {
                if (reader.IsCompleted) {
                    TakeSnapshot(reader);
                    break;
                }

                if (reader.CurrentLine.Contains("FETCH")) {
                    var state = new MessageState();

                    state.InjectLine(reader.CurrentLine);
                    _items.Add(state);
                    reader.ReadNextLine();
                    continue;
                }

                if (reader.IsStatusUpdate) {
                    reader.Client.InvokeStatusUpdateReceived(reader.CurrentLine);
                    reader.ReadNextLine();
                    continue;
                }

                // skip other responses
                reader.ReadNextLine();
            }
        }
Ejemplo n.º 29
0
        public void WriteMessage(XmlDictionaryWriter writer)
        {
            if (writer == null)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentNullException("writer"), this);
            }
            switch (this.state)
            {
            case MessageState.Created:
                this.state = MessageState.Written;
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceVerbose)
                {
                    TraceUtility.TraceEvent(TraceEventType.Verbose, 0x80014, System.ServiceModel.SR.GetString("TraceCodeMessageWritten"), this);
                }
                this.OnWriteMessage(writer);
                return;

            case MessageState.Read:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenRead")), this);

            case MessageState.Written:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenWritten")), this);

            case MessageState.Copied:
                throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageHasBeenCopied")), this);

            case MessageState.Closed:
                throw TraceUtility.ThrowHelperError(this.CreateMessageDisposedException(), this);
            }
            throw TraceUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("InvalidMessageState")), this);
        }
Ejemplo n.º 30
0
    /// <summary>
    /// Закрывает текущее информационное окно и выполняет соответствующие действия
    /// </summary>
    public void CloseMessage()
    {
        GameMessageLabel.gameObject.SetActive(false);
        switch (GameMessageState)
        {
        case MessageState.startgame:
            Time.timeScale = 1f;
            break;

        case MessageState.nextlevel:
            prm.CurrentMap = MainController.Instance._LevelEditor.Maps[UnityEngine.Random.Range(0, MainController.Instance._LevelEditor.Maps.Count)];
            UpdateLevelGUI();
            ResetPlayers();
            LoadLevel();
            foreach (Move m in FindObjectsOfType <Move>())
            {
                m.CheckStartParams();
            }
            Time.timeScale = 1f;
            break;

        case MessageState.kill:
            Restart();
            break;
        }
        GameMessageLabel.gameObject.SetActive(false);
        GameMessageState = MessageState.none;
    }
Ejemplo n.º 31
0
 public DefaultMessage(object content, MessageState state = MessageState.Processing)
 {
     MetaData   = new MetaData();
     Content    = content;
     State      = state;
     CreateTime = DateTime.Now;
 }
Ejemplo n.º 32
0
 internal QuerySmResp(PDUHeader header)
     : base(header)
 {
     vMessageID = "";
     vFinalDate = "";
     vMessageState = MessageState.Unknown;
     vErrorCode = 0;
 }
Ejemplo n.º 33
0
 internal QueryResult(
     string messageId,
     DateTimeOffset? finalDate,
     MessageState state,
     int? errorCode)
 {
     MessageId = messageId;
     FinalDate = finalDate;
     State = state;
     ErrorCode = errorCode;
 }
Ejemplo n.º 34
0
 public QueryResponse(
     SmppStatus status,
     uint sequenceNumber,
     string messageId,
     DateTimeOffset? finalDate,
     MessageState messageState,
     int errorCode)
     : base(status, sequenceNumber)
 {
     MessageId = messageId;
     FinalDate = finalDate;
     MessageState = messageState;
     ErrorCode = errorCode;
 }
Ejemplo n.º 35
0
 public MessageHeader(
     string messageID,
     MessageVersion version,
     string identifier,
     byte[] filterCode,
     MessageFilterType filterType,
     MessageState state,
     ErrorCode errorCode,
     SerializeMode serializeMode,
     CommandCode commandCode,
     MessageType messageType)
 {
     this.MessageID = messageID;
     this.Version = version;
     this.State = state;
     this.FilterCode = filterCode;
     this.FilterType = filterType;
     this.ErrorCode = errorCode;
     this.SerializeMode = serializeMode;
     this.CommandCode = commandCode;
     this.Identifier = identifier;
     this.MessageType = messageType;
 }
Ejemplo n.º 36
0
        void MessageProgressCallback.replied(Parameters body, byte[] rawBody)
        {
            OutgoingMessage message = (OutgoingMessage)this;

            lock(message)
            {
                if(state == MessageState.POSTED
                    || state == MessageState.TRANSMITTED)
                {

                    MessageState previousState = state;

                    state = MessageState.REPLIED;
                    reply = body;
                    rawReply = rawBody;

                    if(previousState == MessageState.POSTED)
                    {
                        transmitted = true;
                    }

                    completed = true;
                    Monitor.PulseAll(message);
                }
            }
        }
Ejemplo n.º 37
0
        void MessageProgressCallback.rejected(string reason)
        {
            OutgoingMessage message = (OutgoingMessage)this;

            lock(message)
            {
                if(state == MessageState.POSTED
                    || state == MessageState.TRANSMITTED)
                {

                    MessageState previousState = state;

                    state = MessageState.REJECTED;
                    rejectionReason = reason;

                    if(previousState == MessageState.POSTED)
                    {
                        transmitted = true;
                    }

                    completed = true;
                    Monitor.PulseAll(message);
                }
            }
        }
Ejemplo n.º 38
0
        private bool TryProcessContent()
        {
            if (this.pendingBytes.Sum(ba => ba.Length) >= this.messageLength)
            {
                byte[] bytes = this.GetBytes(this.messageLength);
                NetworkMessage message = new NetworkMessage();
                string m = UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                int spaceIndex = m.IndexOf(' ');
                int pipeIndex = m.IndexOf('|');
                message.MessageCategory = m.Substring(0, pipeIndex);
                message.MessageType = m.Substring(pipeIndex + 1, spaceIndex - pipeIndex - 1);
                message.MessageContent = m.Substring(spaceIndex + 1);
                this.HandleMessage(message);

                this.messageLength = 0;
                this.state = MessageState.WaitingForHeader;
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 39
0
 private bool TryProcessHeader()
 {
     if (this.pendingBytes.Sum(ba => ba.Length) >= 8)
     {
         //get header + length
         byte[] bytes = this.GetBytes(8);
         int length = 0;
         if (NetworkMessage.CheckHeaderMatchAndGetLength(bytes, out length))
         {
             this.state = MessageState.WaitingForContent;
             this.messageLength = length;
         }
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 40
0
 internal bool ChangeState(MessageState from, MessageState to)
 {
     return Interlocked.CompareExchange(ref messageState, (int)to, (int)from) == (int)from;
 }
Ejemplo n.º 41
0
 internal MessageStateInfo(MessageState state, int sentBytes, 
     int totalByteCount, Parameters replyBody, 
     byte[] rawReplyBody, string rejectionReason)
 {
     State = state;
     SentBytes = sentBytes;
     TotalByteCount = totalByteCount;
     ReplyBody = replyBody;
     RawReplyBody = rawReplyBody;
     RejectionReason = rejectionReason;
 }
Ejemplo n.º 42
0
 public Messager(string message, MessageState state)
 {
     Message = message;
     State = state;
 }
Ejemplo n.º 43
0
        private static void Process(MessagesModel model, IEnumerable<FastLogReader.Line> lines)
        {
            Message msg = null;

            var previousState = new MessageState();

            foreach (var line in lines)
            {
                var isTor = Tor.Lines.Contains(line.Host) || DnsCache.ResolveDontWait(line.Host).Any(ipv4 => Tor.Lines.Contains(ipv4));

                msg = msg ?? new Message { UsesTor = isTor, Timestamp = line.When, Nick = line.Nick, Type = line.Type };

                previousState.InitializeIfBlank(line);

                if (previousState.IsLinePartOfMessage(line))
                {
                    msg.Lines.Add(line.Message);
                    continue;
                }

                previousState.SetState(line);

                msg = new Message { UsesTor = isTor, Type = line.Type, Nick = line.Nick, Timestamp = line.When };

                msg.Lines.Add(line.Message);

                model.Messages.Add(msg);
            }
        }
Ejemplo n.º 44
0
 protected override void Parse(ByteBuffer buffer)
 {
     if (buffer == null) { throw new ArgumentNullException("buffer"); }
     vMessageID = DecodeCString(buffer);
     vFinalDate = DecodeCString(buffer);
     vMessageState = (MessageState)GetByte(buffer);
     vErrorCode = GetByte(buffer);
     //This pdu has no option parameters,
     //If the buffer still contains something,
     //the we received more that required bytes
     if (buffer.Length > 0) { throw new TooManyBytesException(); }
 }
Ejemplo n.º 45
0
 public virtual Task<VoatApiResponse<List<UserMessage>>> GetMessages(MessageType type,MessageState state)
 {
     var arguments = new object[] { type,state };
     return (Task<VoatApiResponse<List<UserMessage>>>) methodImpls["GetMessages"](Client, arguments);
 }