Пример #1
0
 protected virtual void OnTransactionReceived(TransactionEventArgs e)
 {
    if (TransactionReceived != null)
       TransactionReceived(this, e);
 }
Пример #2
0
      public void ReceiveTransaction(object sender, TransactionEventArgs e)
      {
         Transaction inTransaction = e.IncomingTransaction;
         Transaction replyTo = e.ReplyToTransaction;

         if (inTransaction == null)
         {
            s_log.ErrorFormat("No incoming transaction!");
            return;
         }

         Type inType = inTransaction.GetType();
         Type replyType = (replyTo == null) ? null : replyTo.GetType();

         s_log.InfoFormat("Received Transaction ID {0} '{1}': ({2})",
                          inTransaction.Id.Value, inTransaction.Name, inType.ToString());

         if (replyTo != null)
         {
            s_log.InfoFormat("In reply to ID {0} '{1}': ({2})",
                             replyTo.Id.Value, replyTo.Name, replyType.ToString());
         }

         // If it has an error code, display the error.
         if (inType == typeof(RelayChat))
            HandleRelayChat(inTransaction as RelayChat);
         else if (inType == typeof(Disconnected))
            HandleDisconnected(inTransaction as Disconnected);
         else if (replyType == typeof(Login))
            HandleLoginResponse(inTransaction);
         else if (replyType == typeof(GetUserList))
            HandleGetUserList(inTransaction);
         else if (inType == typeof(UserChange))
            HandleUserUpdate(inTransaction as UserChange);
         else if (inType == typeof(UserLeave))
            HandleUserLeave(inTransaction as UserLeave);
         else if (inType == typeof(PmReceive))
            HandleReceivePm(inTransaction as PmReceive);
         else if (replyType == typeof(GetUserInfo))
            HandleGotUserInfo(inTransaction);
         else if (inType == typeof(Transaction))
            s_log.WarnFormat("Unsupported Transaction received: {0}", inTransaction.Id.Value);
         else if (inTransaction.ErrorCode > 0)
            HandleError(inTransaction);
         else 
            s_log.WarnFormat("Unsupported Transaction {0} '{1}' received: ({2})",
                             inTransaction.Id.Value, inTransaction.Name, inTransaction.GetType().ToString());

         return;
      }