Esempio n. 1
0
 public override int HandleCommand(CommandContext context, ISyncResult result)
 {
     try
     {
         SessionRequestCommand sRequestCommand = SessionRequestCommand.ParseFrom(context.sSerializeObject);
         if (!sRequestCommand.HasCommandId)
         {
             CLRLogger.GetInstance().LogDevError("commandID error.");
             result.SetSerializedString("commandID error.");
             return(-1);
         }
         byte[] invokeResult = _dicFunc[sRequestCommand.CommandId].Invoke(sRequestCommand);
         if (null == invokeResult)
         {
             return(-1);
         }
         result.SetSerializedObject(invokeResult);
         return(0);
     }
     catch (Exception ex)
     {
         CLRLogger.GetInstance().LogDevError("HandleCommand error:" + ex.Message);
         return(-1);
     }
 }
 /// <summary>
 /// handle command
 /// </summary>
 /// <param name="context">CommandContext</param>
 /// <param name="result">ISyncResult</param>
 /// <returns></returns>
 public override int HandleCommand(CommandContext context, ISyncResult result)
 {
     try
     {
         SessionRequestCommand sCommand = SessionRequestCommand.ParseFrom(context.sSerializeObject);
         if (!sCommand.HasCommandId || sCommand.ParametersCount < 1)
         {
             result.SetSerializedObject(new byte[] {});
             return(-1);
         }
         ByteString invokeResult = _funDic[sCommand.CommandId].Invoke(sCommand);
         if (null == invokeResult)
         {
             return(-1);
         }
         result.SetSerializedObject(invokeResult.ToByteArray());
         return(0);
     }
     catch (Exception ex)
     {
         CLRLogger.GetInstance().LogDevError("HandleCommand error:" + ex.Message);
         return(-1);
     }
 }