Beispiel #1
0
 // Failure
 public RpcReturn(RpcCall call, string exceptionName, string exceptionMessage)
 {
     Call = call;
     Success = false;
     ExceptionName = exceptionName;
     ExceptionMessage = exceptionMessage;
 }
        public bool TryDecodeCalls(Stream inputStream, out IList<RpcCall> calls)
        {
            if (null == inputStream) {
                throw new ArgumentNullException("inputStream");
            }

            // Convert raw data into calls
            // [callid,methodid,param1,param2..paramN]\n[callid,methodid,param1,param2..paramN]\n...

            try {
                // Catch blank request
                if (inputStream.Length < 1) {
                    calls = null;
                    return false;
                }

                // Read input to string
                var inputString = inputStream.ReadAllToString();

                // Convert string to calls
                var callsString = inputString.Split('\n');

                // Iterate each call
                calls = new List<RpcCall>();
                ArrayList deserialisedData;
                RpcCall call;
                foreach (var callString in callsString) {
                    deserialisedData = Json.Deserialize<ArrayList>(callString);

                    call = new RpcCall((string)deserialisedData[1]);
                    call.CallId = (int)deserialisedData[0];
                    call.MethodParameters = deserialisedData.GetRange(2, deserialisedData.Count - 2).ToArray();
                    calls.Add(call);
                }

                return true;
            } catch (Exception) {
                calls = null;
                return false;
            };
        }
Beispiel #3
0
 // Success
 public RpcReturn(RpcCall call, object[] methodParameters)
 {
     Call = call;
     Success = true;
     ReturnParameters = methodParameters;
 }