StartClient() private static method

private static StartClient ( ) : void
return void
Exemplo n.º 1
0
    public void ChangeToGame()
    {
        string status = AsynchronousClient.StartClient(username, password);

        Debug.Log(" *** " + status);
        if (status != "Incorrect")
        {
            Application.LoadLevel("MainScene");
        }
        else
        {
        }
    }
Exemplo n.º 2
0
        }//LoginPage for insert Username and Password

        public IActionResult Index(User user)
        {
            if (LogInControl(user))
            {
                string json = JsonConvert.SerializeObject(user);
                AsynchronousClient.Send(AsynchronousClient.StartClient(), json);

                return(View());
            }
            else
            {
                return(View("LogIn", user));
            }
        }//Index Page who call LogInControl
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var _btn1 = FindViewById <Button>(Resource.Id.btn1);
            var _btn2 = FindViewById <Button>(Resource.Id.btn2);
            var _btn3 = FindViewById <Button>(Resource.Id.btn3);
            var _btn4 = FindViewById <Button>(Resource.Id.btn4);
            var _txt2 = FindViewById <TextView>(Resource.Id.txt2);


            _btn1.Click += delegate
            {
                AsynchronousClient.StartClient();
            };



            var signal = new ManualResetEvent(false);

            // or signal = new AutoResetEvent(false);
            _btn2.Click += delegate
            {
                signal.Reset();
                var newThreead = new Thread(() =>
                {
                    RunOnUiThread(() =>
                    {
                        _txt2.Text = "Wait....";
                    });

                    signal.WaitOne();

                    RunOnUiThread(() =>
                    {
                        _txt2.Text = "Done...";
                    });
                });
                newThreead.Start();
            };

            _btn3.Click += delegate
            {
                signal.Set();
            };
        }
        public override void DoJob()
        {
            //List<InstrumentDataEnQueueJob> jobList = new List<InstrumentDataEnQueueJob>();

            //List<AsynchronousClient> asynchronousClientList = new List<AsynchronousClient>();

            //foreach (var item in jobList)
            //{
            //    AsynchronousClient client = new AsynchronousClient();
            //    asynchronousClientList.Add(client);
            //}

            // check number calc server

            List<Task> taskList = new List<Task>();

            while ( this.calculationComplete() )
            {
                // 쌓인 것중에 하나 가져옴 다 가져왔음?
                InstrumentData instrumentData = this.getInstrumentData();

                // 살아있는 서버 찾음.
                TargetServerInfoViewModel tsivm = this.AliveServer();

                // 연결함.
                AsynchronousClient client = new AsynchronousClient(tsivm);

                //
                Task task = new Task(() => { client.StartClient(instrumentData); });
                task.Start();
                taskList.Add(task);

                if (!this.calculationAvailable())
                {
                    int completeIndex = Task.WaitAny(taskList.ToArray());
                }
                
            }

            //for (int i = 0; i < taskArray.Length; i++)
            //{
            //    Console.WriteLine(asynchronousClientList[i].RecieveData_);
            //    //results[i] = taskArray[i].Result;
            //}
        }
Exemplo n.º 5
0
 public static void newThreadClient(Menu menu)
 {
     // Tant que le thread n'est pas tué, on travaille
     while (Thread.CurrentThread.IsAlive)
     {
         // Attente de 2000 ms
         Thread.Sleep(1000);
         // Affichage dans la console
         Client cli = new Client();
         cli.Attach();
         cli.parler();    //maitre va lui dire ou il va etre
         cli.placement(); //amitre de rang va l'accompagenr a la table choisie avant
         Console.WriteLine(cli.clientX);
         Console.WriteLine(cli.clientY);
         AsynchronousClient.StartClient(cli.commande(menu).Item1 + "<EOF>");
         cli.payer(menu);
         threadSuper();
     }
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine($"This is a Client");

            AsynchronousClient asynchronousClient = new AsynchronousClient(10000);

            asynchronousClient.msgReceiveEvent += Handle;
            asynchronousClient.StartClient();

            //Subscribe(asynchronousClient);

            //Thread.Sleep(200);

            // Publish(asynchronousClient);

            //Publish(asynchronousClient);

            //Publish(asynchronousClient);

            while (true)
            {
                var input = Console.ReadLine();
                if (input == "1")
                {
                    Subscribe(asynchronousClient);
                }
                else if (input == "2")
                {
                    Publish(asynchronousClient);
                }
                else if (input == "9")
                {
                    login(asynchronousClient);
                }
                else if (input == "exit")
                {
                    break;
                }
            }

            Console.ReadLine();
        }
Exemplo n.º 7
0
        public void Play(Label txtKron, Playlist playlist, ProgressBar progress, bool isSpectrumOn)
        {
            _player             = new System.Windows.Media.MediaPlayer();
            _player.MediaEnded += delegate { NextSong(playlist, txtKron, progress, isSpectrumOn); };
            SongNameLabel(txtKron, playlist.listOfFiles[0][1]);
            if (playlist.listOfFiles[0][2] == ".wav" && isSpectrumOn == true)
            {
                //UnityLaunch();
                //Thread.Sleep(2150);
                //Thread.Sleep(2485);
                AsynchronousClient.StartClient(playlist.listOfFiles[0][0]);
            }
            Uri uri = new Uri(playlist.listOfFiles[0][0]);

            _player.Open(uri);
            _player.MediaOpened += delegate { SetMax(progress); };
            currentSongID        = 0;
            _player.Play();
            SetTimer(progress);
            _player.Volume = volume;
        }
Exemplo n.º 8
0
        public HttpResponseMessage Post(dynamic value)
        {
            HttpResponseMessage response;
            string data = JsonConvert.SerializeObject(value);

            try
            {
                //Socketcmd socketcmd = JsonConvert.DeserializeObject<Socketcmd>(data);
                //GlobalVariables.cmd = socketcmd;
                GlobalVariables.cmd = JsonConvert.DeserializeObject <Socketcmd>(data);
                if (GlobalVariables.GlobalSocketList != null)
                {
                    if (GlobalVariables.GlobalSocketList.Count > 0)
                    {
                        //response = Request.CreateResponse(HttpStatusCode.OK, @"{""Status"": ""There are " + GlobalVariables.GlobalSocketList.Count + @" connections running. Please stop the current connections to create more connections.""}");
                        return(SocketHelper.SocketHelperConnectionStatus());
                        //@"{""Status"": ""There are " + GlobalVariables.GlobalSocketList.Count + @" connections opened.""}"
                    }
                    else
                    {
                        GlobalVariables.GlobalSocketList = AsynchronousClient.StartClient(GlobalVariables.cmd);
                        //GlobalVariables.GlobalSocketList = AsynchronousClient.StartClient(GlobalVariables.cmd.Host, GlobalVariables.cmd.Port, GlobalVariables.cmd.Connections);
                        //response = Request.CreateResponse(HttpStatusCode.OK, @"{""Status"": ""Requests created " + GlobalVariables.GlobalSocketList.Count + @" number of connections.""}");
                        return(SocketHelper.SocketHelperConnectionStatus());
                    }
                }
                else
                {
                    GlobalVariables.GlobalSocketList = AsynchronousClient.StartClient(GlobalVariables.cmd);
                    //response = Request.CreateResponse(HttpStatusCode.OK, @"{""Status"": ""Requests created " + GlobalVariables.GlobalSocketList.Count + @" number of connections.""}");
                    return(SocketHelper.SocketHelperConnectionStatus());
                }
            }
            catch (Exception e)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Exception: " + e.Message);
                return(response);
            }
            return(response);
        }
Exemplo n.º 9
0
        // Works
        private static void ClientMethod2()
        {
            string request     = "GET";
            string HCN         = "1231321321";
            string vCode       = "ZZ";
            string postalCode  = "A1N1N1";
            string finalString = request + " " + HCN + "," + vCode + "," + postalCode + "<EOF>";

            Console.WriteLine("{0}", finalString);

            AsynchronousClient client2 = new AsynchronousClient("client2");

            client2.StartClient("127.0.0.1");
            client2.SendMessage("GET 1134567983,BA,N2H4J2/1234567981,AB,N2H4J4/1234567982,AC,N2H3J5");
            string client2Response = client2.ReceiveMessage();

            Console.WriteLine("\n--------------------------------------------");
            Console.WriteLine("\nClient 2 received: {0}\n", client2Response);
            Console.WriteLine("--------------------------------------------\n");
            if (client2Response != "VCODE")
            {
                numberOfErrors2++;
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            AsynchronousClient client = new AsynchronousClient();

            client.StartClient("127.0.0.1", 11000);
        }
 public static void testSendSockeToParallelCalcM_Server()
 {
     AsynchronousClient.StartClient();
 }
        /// <summary>
        /// Saves changes
        /// </summary>
        public void SaveRSPButtonChanges(object parameter)
        {
            //Deug purposes
            //Console.WriteLine(parameter.ToString());

            switch (parameter.ToString())
            {
            case "Rock":
                Game.playersChoice = RoPaSc.Rock;
                //Console.WriteLine(Game.addresIpV4);
                break;

            case "Paper":
                Game.playersChoice = RoPaSc.Paper;
                break;

            case "Scissors":
                Game.playersChoice = RoPaSc.Scissors;
                break;
            }

            string responseFromServer = AsynchronousClient.StartClient(Game.addresIpV4, Game.port);

            if (responseFromServer == "Rock")
            {
                Game.aiChoice = RoPaSc.Rock;
            }
            else if (responseFromServer == "Paper")
            {
                Game.aiChoice = RoPaSc.Paper;
            }
            else if (responseFromServer == "Scissors")
            {
                Game.aiChoice = RoPaSc.Scissors;
            }

            if (Game.playersChoice == Game.aiChoice)
            {
                Game.lastResult = "Draw";
            }
            else if (Game.playersChoice == RoPaSc.Rock && Game.aiChoice == RoPaSc.Paper)
            {
                Game.lastResult = "AI wins";
                Game.scoreAI   += 1;
            }
            else if (Game.playersChoice == RoPaSc.Rock && Game.aiChoice == RoPaSc.Scissors)
            {
                Game.lastResult   = "You win";
                Game.scorePlayer += 1;
            }
            else if (Game.playersChoice == RoPaSc.Paper && Game.aiChoice == RoPaSc.Rock)
            {
                Game.lastResult   = "You win";
                Game.scorePlayer += 1;
            }
            else if (Game.playersChoice == RoPaSc.Paper && Game.aiChoice == RoPaSc.Scissors)
            {
                Game.lastResult = "AI wins";
                Game.scoreAI   += 1;
            }
            else if (Game.playersChoice == RoPaSc.Scissors && Game.aiChoice == RoPaSc.Rock)
            {
                Game.lastResult = "AI wins";
                Game.scoreAI   += 1;
            }
            else if (Game.playersChoice == RoPaSc.Scissors && Game.aiChoice == RoPaSc.Paper)
            {
                Game.lastResult   = "You win";
                Game.scorePlayer += 1;
            }
        }
Exemplo n.º 13
0
 static void Main(string[] args)
 {
     AsynchronousClient.StartClient();
     Console.Read();
 }
Exemplo n.º 14
0
 public bool Login()
 {
     return(AsynchronousClient.StartClient());
 }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            debugFlag = true;
            Console.WriteLine("Litetouch 5000LC CCU Time Update Utility\n");
            if (args.Length == 0)
            {
                Console.WriteLine("This utility updates the time on a Litetouch 5000LC CCU.\n");

                Console.WriteLine("XXX.XXX.XXX.XXX = First argument is the Target CCU Host Address (IPv4 Address, FQDN, etc)");
                Console.WriteLine("-c = Use Computer Clock");
                Console.WriteLine("-i = Use Internet Time Service (time.nist.gov) (Default)");
                Console.WriteLine("-z = Check CCU Clock only. (No Update)");

                Console.WriteLine("Example Usage: \n\tLitouch5000LCTimeUpdate 192.168.1.10 -i\n\tUpdates the CCU at 192.168.1.10 with time.nist.gov");
            }
            else
            {
                //First argument should be a network or web address
                //Let's attempt to gather that
                string targetCCUaddress = getIPAddress(args[0]);
                if (debugFlag)
                {
                    Console.WriteLine("Target CCU:" + targetCCUaddress);
                }
                //If there is a second argument, it should specify the update type
                bool noUpdate       = false;
                bool internetUpdate = true;
                if (args.Length >= 2)
                {
                    switch (args[1])
                    {
                    case "-c":
                    {
                        internetUpdate = false;
                        break;
                    }

                    case "-i":
                    {
                        internetUpdate = true;
                        break;
                    }

                    case "-z":
                    {
                        noUpdate = true;
                        break;
                    }
                    }
                }
                //We ignore further arguments


                //Now we grab the CCU's reported time
                AsynchronousClient targetCCU = new AsynchronousClient();
                targetCCU.StartClient(targetCCUaddress, 10001);     //Default Port for Litetouch Control = 10001

                //Send "GET CLOCK" Command to CCU
                //Format = R,DGCLK
                string commandString  = "R,DGCLK\r";
                string responseString = "";
                targetCCU.SendCommand(commandString);
                responseString = targetCCU.ReceiveResponse();
                if (debugFlag)
                {
                    Console.WriteLine("Command Sent: " + commandString);
                    Console.WriteLine("Response Received: " + responseString);
                }


                //DateTime oldTime = getCCUTime(targetCCUaddress);

                DateTime oldTime = convertCCUTimeResponse(responseString);
                Console.WriteLine("Old CCU Time:" + oldTime.ToString("yyyy-MM-dd HH:mm:ss"));


                //If we update, we get time from our sources, and then push to CCU
                DateTime newTime = DateTime.Parse("1900-01-01");  //Pre-assigned clearly wrong date, in case anything goes wrong
                if (!noUpdate)
                {
                    if (internetUpdate)
                    {
                        newTime = getInternetTime();
                        if (debugFlag)
                        {
                            Console.WriteLine("NTP Server Time:" + newTime.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    else
                    {
                        newTime = getComputerTime();
                        if (debugFlag)
                        {
                            Console.WriteLine("Computer Clock Time:" + newTime.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    commandString = convertNewCCUTime(newTime);

                    //Send "SET CLOCK" Command to CCU
                    //Format = R,DSCLK,yyyymmddhhmmss
                    targetCCU.SendCommand(commandString);
                    if (debugFlag)
                    {
                        Console.WriteLine("Time Update Command Sent:" + commandString);
                    }

                    //Send "GET CLOCK" Command to CCU
                    //Format = R,DGCLK
                    commandString  = "R,DGCLK\r";
                    responseString = "";
                    targetCCU.SendCommand(commandString);
                    responseString = targetCCU.ReceiveResponse();
                    if (debugFlag)
                    {
                        Console.WriteLine("Command Sent: " + commandString);
                        Console.WriteLine("Response Received: " + responseString);
                    }

                    DateTime updatedTime = convertCCUTimeResponse(responseString);
                    Console.WriteLine("Old CCU Time:" + oldTime.ToString("yyyy-MM-dd HH:mm:ss"));

                    //Calculate the difference between the times. If they are less than a 10s apart, we will accept it
                    TimeSpan duration = updatedTime - newTime;
                    Console.WriteLine("Old CCU Time: " + oldTime);
                    Console.WriteLine("Updated Time: " + newTime);
                    Console.WriteLine("CCU Time: " + updatedTime);
                    Console.WriteLine("Difference:" + duration.TotalSeconds + " seconds");
                    if (duration.TotalSeconds < 10)
                    {
                        Console.WriteLine("Success: " + oldTime);
                    }
                    else
                    {
                        Console.WriteLine("Something went wrong.");
                    }
                }
                targetCCU.StopClient();
                Console.WriteLine("Finished");
            }

            if (debugFlag)
            {
                Console.WriteLine("End of Program");
            }
        }
Exemplo n.º 16
0
        public string Submit(string userName, string passWord, string filePath, string ctId)
        {
            string type = "";

            Console.WriteLine(Path.GetExtension(filePath));
            switch (Path.GetExtension(filePath)?.ToLower())
            {
            case ".c":
                type = "c";
                break;

            case ".cpp":
                type = "c++";
                break;

            case ".py":
                type = "py";
                break;

            case ".py3":
                type = "py3";
                break;

            case ".sh":
                type = "sh";
                break;

            case ".java":
                type = "java";
                break;
            }



            //  Console.WriteLine(request);
            try
            {
                string str;
                //using (NetworkStream stream = Client.GetStream())
                //{
                //    MessageBox.Show($"submit {userName} {passWord} {ctId} {type} EOF");

                //    var dataOne = Encoding.ASCII.GetBytes($"submit {userName} {passWord} {ctId} {type} EOF");
                //    var newLine = Encoding.ASCII.GetBytes(Environment.NewLine);
                //    var eOf = Encoding.ASCII.GetBytes("EOF");
                //    stream.Write(dataOne, 0, dataOne.Length);
                //    stream.Write(newLine, 0, newLine.Length);
                //    Client.Client.SendFile(filePath);
                //    stream.Write(eOf, 0, eOf.Length);
                //    stream.Write(newLine, 0, newLine.Length);


                //    byte[] data1 = new byte[1024];
                //    using (MemoryStream ms = new MemoryStream())
                //    {


                //        int numBytesRead;
                //        while ((numBytesRead = stream.Read(data1, 0, data1.Length)) > 0)
                //        {
                //            ms.Write(data1, 0, numBytesRead);


                //        }
                //        str = Encoding.ASCII.GetString(ms.ToArray(), 0, (int)ms.Length);
                //    }
                //}
                obj = new AsynchronousClient(Hostname, Port);
                str = obj.StartClient(userName, passWord, filePath, ctId, type);


                Console.WriteLine($"[{str}]");

                return(str);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
 private void btnSend_Click_1(object sender, RoutedEventArgs e)
 {
     AsynchronousClient c = new AsynchronousClient();
     c.StartClient();
     tbxMessage.Text = mainStr;
 }
Exemplo n.º 18
0
 public void StartTest()
 {
     AsynchronousClient.StartClient();
 }
Exemplo n.º 19
0
        public void UpdateProductInfo()
        {
            ClearUpdateInfoLog();

            // evaluete local server from db
            string localServer = m_selectedProduct.LocalServer;

            UpdateEventArgs args = new UpdateEventArgs(m_selectedType, m_updateInfoValue, localServer, m_selectedProduct.Name);

            // start a connection with market branch and wait request, Tcp client part
            AsynchronousClient tcpClient = new AsynchronousClient(m_selectedMarketBranch.TcpServiceInfo, args);
            bool response = tcpClient.StartClient();

            // according to response do smthg here

            if (response)
            {
                if (m_selectedType == UpdateType.Image)
                {
                    m_selectedProduct.UpdateImage(new ImageUpdate(DateTime.Now, args.NewValue, m_validatedUserName));
                    addUpdateInfoLog(string.Format("Product Image is updated to -> {0}", args.NewValue));

                    // update db records
                    // connect to database to update product informations
                    MongoServerSettings settings = new MongoServerSettings();
                    MongoServer         server   = new MongoServer(settings);
                    server.Connect();

                    MongoDatabase db = server.GetDatabase("DigitalPriceCenter");

                    var countries = db.GetCollection("Countries");

                    countries.Save <Country>(m_selectedCountry);

                    server.Disconnect();
                }
                else if (m_selectedType == UpdateType.Info)
                {
                    m_selectedProduct.UpdateInfo(new InfoUpdate(DateTime.Now, args.NewValue, m_validatedUserName));
                    addUpdateInfoLog(string.Format("Product Info is updated to -> {0}", args.NewValue));

                    // update db records
                    // connect to database to update product informations
                    MongoServerSettings settings = new MongoServerSettings();
                    MongoServer         server   = new MongoServer(settings);
                    server.Connect();

                    MongoDatabase db = server.GetDatabase("DigitalPriceCenter");

                    var countries = db.GetCollection("Countries");

                    countries.Save <Country>(m_selectedCountry);

                    server.Disconnect();
                }
                else if (m_selectedType == UpdateType.Price)
                {
                    App.Current.Dispatcher.Invoke((Action) delegate
                    {
                        double price;
                        if (double.TryParse(m_updateInfoValue, out price))
                        {
                            m_selectedProduct.UpdatePrice(new PriceUpdate(DateTime.Now, price, m_validatedUserName));
                        }
                    });

                    addUpdateInfoLog(string.Format("Product Price is updated to -> {0}", args.NewValue));

                    // update db records
                    // connect to database to update product informations
                    MongoServerSettings settings = new MongoServerSettings();
                    MongoServer         server   = new MongoServer(settings);
                    server.Connect();

                    MongoDatabase db = server.GetDatabase("DigitalPriceCenter");

                    var countries = db.GetCollection("Countries");

                    countries.Save <Country>(m_selectedCountry);

                    server.Disconnect();
                }
            }

            // fail message
            else
            {
                if (m_selectedType == UpdateType.Image)
                {
                    addUpdateInfoLog(string.Format("SORRY : Product Image is not updated, TRY AGAIN!"));
                }
                else if (m_selectedType == UpdateType.Info)
                {
                    addUpdateInfoLog(string.Format("SORRY : Product Info is not updated, TRY AGAIN!"));
                }
                else if (m_selectedType == UpdateType.Price)
                {
                    addUpdateInfoLog(string.Format("SORRY : Product Price is not updated, TRY AGAIN!"));
                }
            }
        }
Exemplo n.º 20
0
 static void Main(string[] args)
 {
     //TClient client = new TClient();
     //client.start();
     AsynchronousClient.StartClient();
 }
        private void Btn_Login_Click(object e)
        {
            try
            {
                PasswordBox pwBox = e as PasswordBox;
                string      pwd   = UtilityLoginDetails.GETInstance.DecryptedPassword = pwBox.Password;

                bool validate = ValidateInputFields(pwd);
                if (!validate)
                {
                    return;
                }

                //Register Event for receiving Logon Response
                //  MemoryManager.OnLogonReplyReceived += MemoryManager_OnLogonReplyReceived;
                LoginProcessor oLoginProcessor = new LoginProcessor();

                MemoryManager.InitializeDefaultMemory();

                LogonRequest oLogonRequest = new LogonRequest();


                //initialze socket
                AsynchronousClient.StartClient();

                //initiate receive
                ReceiverController oReceiverController = new ReceiverController();
                oReceiverController.ReceiveMessage();

                //initiate UMS
                UMSController oUMSController = new UMSController();
                oUMSController.ReceiveUMSMessage();

                //if (BcastEquityChkBx)
                //{
                //    //start receiving broadcast
                //    BroadCastProcessor.objBroadcastController = new BroadcastController();
                //    BroadCastProcessor.objBroadcastController.ConnectToBroadCastServer();
                //}

                if (EquitySegChk)
                {
                    //oLogonRequest.Exchange = 1; //1 - Equity, 2- Derv., 3. Curr
                    CreateEQXloginRequest(pwd, ref oLogonRequest);
                    oLoginProcessor.ProcessData(oLogonRequest);
                }


                //if (DerivativeChkBx)
                //{
                //    CreateDERloginRequest(pwd, ref oLogonRequest);
                //    oLoginProcessor.ProcessData(oLogonRequest);
                //}
                //if (CurrencyChkBx)
                //{
                //    CreateCURloginRequest(pwd, ref oLogonRequest);
                //    oLoginProcessor.ProcessData(oLogonRequest);

                //}
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
        }
Exemplo n.º 22
0
 private void serverCliTestBtn_Click(object sender, RoutedEventArgs e)
 {
     AsynchronousClient.StartClient();
 }
Exemplo n.º 23
0
 public static void Main()
 {
     AsynchronousClient.StartClient();
 }
Exemplo n.º 24
0
 // Lancer la connexion de côté
 private static void tentative_connection_serveur_DoWork(object sender, DoWorkEventArgs e)
 {
     ((BackgroundWorker)sender).ReportProgress(0, AsynchronousClient.StartClient("0000000001"));
 }