Exemple #1
0
        public async Task <string> CallFunction(string address, string name, string[] args)
        {
            // --------------------- Implement ---------------------
            string ip   = address.Split(":")[0];
            int    port = int.Parse(address.Split(":")[1]);

            string payload = "rpc:" + name + ":" + string.Join(",", args);

            string answer = await TcpRequest.Do(ip, port, payload + "\n");

            answer = answer.Substring(0, answer.IndexOf("\0")); //deleting all \0 of buffer for printing
            return(answer);

            // TODO: Contact server and pass procedure call
            if (name != null)
            {
                // Create MyClass object
                Server myServerObj = new Server(this);
                // Get the Type information.
                Type myTypeObj = myServerObj.GetType();
                // Get Method Information.
                MethodInfo myMethodInfo = myTypeObj.GetMethod(name);
                object[]   mParam       = (object[])args;
                // Get and display the Invoke method.
                object answerObj = myMethodInfo.Invoke(myServerObj, mParam);

                answer = (string)answerObj;
            }

            // --------------------- /Implement -------------------
        }
Exemple #2
0
        public async Task <string> CallFunction(string address, string name, string[] args)
        {
            // --------------------- Implement ---------------------
            string ip   = address.Split(':')[0];
            int    port = int.Parse(address.Split(':')[1]);

            string payload = "rpc:" + name + ":" + String.Join(",", args);

            string answer = await TcpRequest.Do(ip, port, payload + "\n");

            return(answer);
            // --------------------- /Implement -------------------
        }
Exemple #3
0
        public async Task <string> SendObjectTo(string address, object input)
        {
            string ip   = address.Split(':')[0];
            int    port = int.Parse(address.Split(':')[1]);

            string payload = Marshall(input);

            Console.WriteLine("\n\r  Middleware: Transferring payload '{0}' to {1}:{2}\n\r", payload, address, port);

            string answer = await TcpRequest.Do(ip, port, payload + "\n");

            return(answer);
        }