private async Task <bool> ContinueProcessing(ContinueProcessing msg)
        {
            WebSocketReceiveResult res = null;

            try
            {
                var cancellationTokenSource = new CancellationTokenSource(msg.ReceiveTimeout);
                res = await _cws.ReceiveAsync(_receiveSegment, cancellationTokenSource.Token);
            }
            catch (OperationCanceledException)
            {
                Continue();
                return(true);
            }

            if (res.CloseStatus != null)
            {
                Continue();
                return(true);
            }
            else if (res.Count > 0)
            {
                var message = Encoding.UTF8.GetString(_receiveSegment.Array, _receiveSegment.Offset, res.Count);
                _messageProcessorActor.Tell(new MessageReceived(message, DateTime.UtcNow));
            }
            Continue();
            return(true);
        }
Beispiel #2
0
 public void LengthOperation(ContinueProcessing pred)
 {
     while(true)
     {
         if(pred() == false)
         {
             break;
         }
     }
 }
Beispiel #3
0
 public void LengthOperation2(ContinueProcessing pred)
 {
     bool bContinue = true;
     while (true)
     {
         foreach(ContinueProcessing pr in pred.GetInvocationList())
         {
             bContinue &= pr();
         }
         if(false == bContinue)
         {
             break;
         }
     }
 }
Beispiel #4
0
 public void Func1()
 {
     ContinueProcessing cp = new ContinueProcessing(IsComplete);
     cp += new ContinueProcessing(IsComplete2);
     LengthOperation(cp);
 }