Ejemplo n.º 1
0
 public override void processERROR(string message)
 {
     // the error is a serious one and we cannot identify the related request;
     // we can't but close the whole session
     log.Error("Closing the session because of unexpected error: " + message);
     try
     {
         ERRORParser parser = new ERRORParser(message);
         forwardControlResponseError(parser.errorCode, parser.errorMsg, null);
     }
     catch (ParsingException e)
     {
         onIllegalMessage(e.Message);
     }
 }
 internal virtual void dispatchMessages()
 {
     /* Abnormal conditions are:
      * - the presence of ERROR messages
      * - an unexpected number of responses
      */
     if (messages.Count == 1 && messages[0].StartsWith("ERROR", StringComparison.Ordinal))
     {
         outerInstance.log.Error("Control request returned an ERROR message: " + messages);
         string message = messages[0];
         try
         {
             ERRORParser parser = new ERRORParser(message);
             throw new ProtocolErrorException("" + parser.errorCode, parser.errorMsg);
         }
         catch (ParsingException)
         {
             throw new ProtocolErrorException("61", "Unexpected response to control request: " + message);
         }
     }
     else if (messages.Count != listeners.Count)
     {
         outerInstance.log.Error("Control request returned an unexpected number of responses: " + messages);
         throw new ProtocolErrorException("61", "The number of received responses is different from the number of batched requests");
     }
     else
     {
         // check whether there is an ERROR message
         foreach (string msg in messages)
         {
             if (msg.StartsWith("ERROR", StringComparison.Ordinal))
             {
                 outerInstance.log.Error("Control request returned at least an ERROR message: " + messages);
                 throw new ProtocolErrorException("61", "A batch of requests returned at least an ERROR message");
             }
         }
     }
     /* no ERROR message: process the responses */
     for (int i = 0; i < messages.Count; i++)
     {
         listeners[i].onMessage(messages[i]);
     }
 }