Esempio n. 1
0
        public CSClient(string[] args)
        {
            RemoteClass remoteObj = new RemoteClass();

            if( remoteObj.Equals(null) )
            {
                System.Console.WriteLine("Error: unable to locate server");
            }
            else
            {
                string strArgs;
                if (args.Length == 0)
                {
                    strArgs = "Client";
                }
                else
                {
                    strArgs = args[0];
                }

                //remoteObj.WriteName(strArgs);
                //System.Console.WriteLine(remoteObj.ReadWelcome());
                System.Console.ReadLine();
            }
        }
Esempio n. 2
0
        private int sameButtonPushedCount = 0; // tracks the number of times the same button was pushed in a row

        #endregion Fields

        #region Methods

        /// <summary>
        /// Starts this instance.
        /// </summary>
        void IPlugin.Start()
        {
            //File.AppendAllText(@"c:\AverRmHv.txt", "Start Llamado\n\r");

            try
            {
                rc = new RemoteClass();
                rc.Initialize();
                rc.OnRemoteData += RecibeDatos;
                //string mediaportalpath = AppDomain.CurrentDomain.ApplicationIdentity.FullName;
                string mediaportalpath = System.Reflection.Assembly.GetEntryAssembly().FullName;
                rc.SwitchBeginAP(mediaportalpath);
                Log.Info("AverRMHV Plugin: Started by " + mediaportalpath);
                //File.AppendAllText(@"c:\AverRmHv.txt", "Inicialización Correcta. Path = " + mediaportalpath);

            }
            catch (Exception e)
            {
                //File.AppendAllText(@"c:\AverRmHv.txt", "Error en Start\n\r");
                Log.Error("AverRMHV Plugin: AverRemote.exe not responding");
                Log.Error("AverRMHV Plugin: Exception: "+e);
            }

            inputhandler = new InputHandler(mappingfile);
            if (inputhandler == null || !inputhandler.IsLoaded)
            {
                //File.AppendAllText(@"c:\AverRmHv.txt", "AverRMHV Plugin: File " + mappingfile + " not loaded.\n\r");
                Log.Error("AverRMHV Plugin: File " + mappingfile + " not loaded.");
            }
            lastTimeActionPerformed = DateTime.Now;
            lastTimeButtonPushed = DateTime.Now;
            Log.Info("AverRMHV Plugin: Started.");
        }
Esempio n. 3
0
        public static void Main(string [] args)
        {
            RemotingConfiguration.Configure("Client.exe.config", false);
            RemoteClass remoteObj = new RemoteClass();

            if( remoteObj.Equals(null) )
            {
                System.Console.WriteLine("Error: unable to locate server");
            }
            else
            {
                string strArgs;
                if (args.Length == 0)
                {
                    strArgs = "Client";
                }
                else
                {
                    strArgs = args[0];
                }

                //remoteObj.WriteName(strArgs);
                //System.Console.WriteLine(remoteObj.ReadWelcome());
                System.Console.ReadLine();
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            RemotingConfiguration.Configure("RemotingServer.exe.config", false);
            rmt = new RemoteClass();
            RemotingServices.Marshal((rmt), "RemoteClass");

            Console.WriteLine("The Server is ready .... Press the enter key to exit...");
            Console.ReadLine();
        }
Esempio n. 5
0
	public bool reponse_message(ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<Int32,Int32> dic_test, string msg )
	{
		ZNet.CMessage Msg = new ZNet.CMessage();
		ZNet.PacketType msgID = (ZNet.PacketType)Common.reponse_message; 
		
		Msg.WriteStart( msgID, pkOption, 0, true );

		RemoteClass.Marshaler.Write( Msg, testClass );
		RemoteClass.Marshaler.Write( Msg, dic_test );
		RemoteClass.Marshaler.Write( Msg, msg );

		return PacketSend( remote, pkOption, Msg );
	} 
Esempio n. 6
0
        public static void Start()
        {
            TcpListener tcp = new TcpListener(IPAddress.Loopback, 11223);

            tcp.Start();
            doListen = true;

            RemoteClass myclass = new RemoteClass();

            myclass.AddMethod("Say_IntString", (client, args) =>
            {
                List <object> list = NetStruct.UnpackFmt(args, 0, "isf");
                if (list == null)
                {
                    return(false);
                }

                int i    = (int)list[0];
                string s = (string)list[1];
                float f  = (float)list[2];
                Console.WriteLine($"Say_IntString(): {i}, '{s}', {f}");
                return(true);
            });
            myclass.AddMethod("CloseServer", (client, args) =>
            {
                Console.WriteLine("CloseServer(): Got request to close the server");
                doListen = false;
                return(true);
            });

            do
            {
                TcpClient    client = tcp.AcceptTcpClient();
                RemoteClient remote = new RemoteClient(client, myclass);
                double       flLast = 0.5;
                while (remote.Recv() == RpcCode.Ok)
                {
                    remote.RemoteCall("wazzap", "sf", $"String {flLast}", flLast);
                    flLast += 0.5;
                    remote.Send();
                }
                doListen = false;
                client.Close();
            } while (doListen);

            Console.WriteLine("Stopping server...");
            tcp.Stop();
            doListen = false;
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Configure remoting.
            RemotingConfiguration.Configure(Application.StartupPath + "\\Client.exe.config", false);

            // Create a proxy from remote object.
            remoteClass = (RemoteClass)Activator.GetObject(typeof(RemoteClass), "http://localhost:5000/Chat");
            //Create an instance of wrapper class.
            wrapperClass = new WrapperClass();

            //Associate remote object event with wrapper method.
            remoteClass.MessageReceived += new MessageHandler(wrapperClass.WrapperMessageReceivedHandler);
            //Associate wrapper event with current form event handler.
            wrapperClass.WrapperMessageReceived += new MessageHandler(MessageReceivedHandler);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            #region TCP方式

            /*
             * //1、注册通道
             * TcpChannel tcpChannel = new TcpChannel();//客户端不需要指定端口号
             * ChannelServices.RegisterChannel(tcpChannel, true);
             *
             * //2、创建代理
             * RemoteClass rc = (RemoteClass)Activator.GetObject(typeof(RemoteClass), "tcp://localhost:10000/HelloTest");//1000端口号是服务器端指定的
             * if (rc == null)
             * {
             *  Console.WriteLine("Could not locate TCP Server");
             * }
             * Console.WriteLine("TCP方式{0}", rc.Method("张飞"));
             * //*/

            #endregion

            #region Http方式

            HttpChannel httpChannel = new HttpChannel();
            ChannelServices.RegisterChannel(httpChannel, false);
            RemoteClass object2 = (RemoteClass)Activator.GetObject(typeof(RemoteClass), "http://localhost:10001/HelloTest");
            if (object2 == null)
            {
                Console.WriteLine("Could not locate HTTP Server");
            }

            Console.WriteLine("HTTP方式{0}", object2.Method("关羽"));
            #endregion

            #region 配置文件实现

            RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, true);
            RemoteClass obj = new RemoteClass();

            Console.WriteLine("HTTP方式{0}", obj.Method("祥子"));
            #endregion

            Console.Read();
        }
Esempio n. 9
0
        public static void Start()
        {
            TcpClient tcp = new TcpClient();

            try
            {
                tcp.Connect(IPAddress.Loopback, 11223);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                tcp.Close();
                return;
            }

            RemoteClass myclass = new RemoteClass();

            myclass.AddMethod("wazzap", (client, args) =>
            {
                List <object> list = NetStruct.UnpackFmt(args, 0, "sf");
                if (list == null)
                {
                    return(false);
                }

                Console.WriteLine($"wazzap(): '{(string)list[0]}', '{(float)list[1]}'");
                return(true);
            });

            RemoteClient client = new RemoteClient(tcp, myclass);

            client.RemoteCall("Say_IntString", "isf", 010011, "gANGSTA!", (float)4.20002);
            client.Send();
            client.Recv();
            client.RemoteCall("CloseServer", "");
            client.Send();
            client.Recv();
            tcp.Close();
        }
Esempio n. 10
0
	public bool reponse_message(ZNet.RemoteID[] remotes, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<Int32,Int32> dic_test, string msg )
	{
		foreach(var obj in remotes)
			reponse_message(obj, pkOption, testClass, dic_test, msg );
		return true;
	}
 static void Remote_HelloCallback(object sender, RemoteClass.EventArgsHello e)
 {
     Console.WriteLine("{0} 对 {1} 说 {2}", e.From, e.To, e.Something);
 }
Esempio n. 12
0
        /// <summary>
        /// Create and start this instance of the remote control.
        /// </summary>
        void IPlugin.Start()
        {
            try
            {
                rc = new RemoteClass();
                rc.Initialize();
                rc.OnRemoteData += ReceiveData;
                string mediaportalpath = System.Reflection.Assembly.GetEntryAssembly().FullName;
                rc.SwitchBeginAP(mediaportalpath);
                Log.Info("AverRMKV Plugin: Started by " + mediaportalpath);
            }
            catch (Exception e)
            {
                Log.Error("AverRMKV Plugin: AverRemote.exe not responding");
                Log.Error("AverRMKV Plugin: Exception: " + e);
            }

            inputhandler = new InputHandler(mappingfile);
            if (inputhandler == null || !inputhandler.IsLoaded)
            {
                Log.Error("AverRMKV Plugin: File " + mappingfile + " not loaded.");
            }
            lastTimeActionPerformed = DateTime.Now;
            lastTimeButtonPushed    = DateTime.Now;
            Log.Info("AverRMKV Plugin: Started.");
        }