Пример #1
0
        public void insimConnectTCP(string host, int port, string adminPassword, string mode, string nameApp, bool isLocal)
        {
            int nbTry  = 0;
            int maxTry = 40;

            tc = new TcpConnection.Connection(host, port);
retryConnect:
            Console.Write("Connecting");
            try
            {
                tc.Connect();
            }
            catch
            {
                if (nbTry++ > maxTry)
                {
                    Console.WriteLine("");
                    throw;
                }
                else
                {
                    System.Threading.Thread.Sleep(1000);
                    Console.Write(".");
                    goto retryConnect;
                }
            }
            Console.WriteLine("");
            Console.WriteLine("Connection OK");
            byte[] inSimInit = InSim.Encoder.ISI(adminPassword, 0, 0, nameApp, isLocal);
            try
            {
                this.Send(inSimInit, inSimInit.Length);
            }
            catch
            {
                throw;
            }
            byte[] recvPacket;
            recvPacket = this.Receive();
            InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket);
            this.connected    = true;
            this.Product      = ver.Product;
            this.Version      = ver.Version;
            this.InSimVersion = ver.InSimVersion;
        }
Пример #2
0
        public void insimConnectTCP(string host, int port, string adminPassword, string mode, string nameApp, bool isLocal )
        {
            int nbTry = 0;
            int maxTry = 40;

            tc = new TcpConnection.Connection(host, port);
        retryConnect:
            Console.Write("Connecting");
            try
            {
                tc.Connect();
            }
            catch
            {
                if (nbTry++ > maxTry)
                {
                    Console.WriteLine("");
                    throw;
                }
                else
                {
                    System.Threading.Thread.Sleep(1000);
                    Console.Write(".");
                    goto retryConnect;
                }

            }
            Console.WriteLine("");
            Console.WriteLine("Connection OK");
            byte[] inSimInit = InSim.Encoder.ISI(adminPassword, 0, 0, nameApp,isLocal);
            try
            {
                this.Send(inSimInit, inSimInit.Length);
            }
            catch
            {
                throw;
            }
            byte[] recvPacket;
            recvPacket = this.Receive();
            InSim.Decoder.VER ver = new InSim.Decoder.VER(recvPacket);
            this.connected = true;
            this.Product = ver.Product;
            this.Version = ver.Version;
            this.InSimVersion = ver.InSimVersion;

        }