Example #1
0
        public static bool CheckIfResponseRequired(TcpMessaging.Command cmd)
        {
            try
            {
                var methodInfo = typeof(Plugin).GetNestedType(cmd.ToString()).GetMethod("Invoke");
                if (methodInfo == null)
                {
                    throw new NullReferenceException("Method not found!");
                }

                return(methodInfo.ReturnType != typeof(void));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #2
0
        public static bool CheckIfValidParameters(TcpMessaging.Command cmd, params object[] args)
        {
            var methodInfo = typeof(Plugin).GetNestedType(cmd.ToString()).GetMethod("Invoke");

            if (methodInfo == null)
            {
                throw new NullReferenceException("Method not found!");
            }

            var parameterInfos = methodInfo.GetParameters();
            var i = 0;

            foreach (var parameter in parameterInfos)
            {
                if (parameter.ParameterType != args[i].GetType())
                {
                    return(false);
                }
                i++;
            }
            return(true);
        }
Example #3
0
 public TcpResponse(TcpMessaging.Command cmd, object res)
 {
     PlayerRequest = cmd;
     Response      = res;
 }
Example #4
0
 public TcpRequest(TcpMessaging.Command cmd, params object[] args)
 {
     PlayerRequest    = cmd;
     Arguments        = args;
     ResponseRequired = CheckIfResponseRequired(cmd);
 }