当前位置: 首页>>代码示例>>C#>>正文


C# Client.connect方法代码示例

本文整理汇总了C#中Client.connect方法的典型用法代码示例。如果您正苦于以下问题:C# Client.connect方法的具体用法?C# Client.connect怎么用?C# Client.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.connect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: activate

        private bool activate(int index)
        {
            this.Cursor = Cursors.WaitCursor;
            string subName = dataGridView1.Rows[index].Cells[1].Value.ToString();
            Globals.AMPSAddin.Application.StatusBar = "Activating subscription " + subName + "...";

            // activate
            try
            {
                var workbook = Globals.AMPSAddin.Application.ActiveWorkbook;
                var ampsWBInfo = Globals.AMPSAddin.getWorkbookInfo(workbook);
                Client c = new Client(Guid.NewGuid().ToString());
                AMPSAddin.ServerDefinition serverDef = ampsWBInfo.Servers[_subs[index].ServerName];
                c.connect(serverDef.URL);
                c.logon();
                ActiveSub.activate(_subs[index], c, serverDef.MessageType, workbook);
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(string.Format("Error activating: {0}", ex.Message),
                    "Error activating subscription "+ subName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Globals.AMPSAddin.Application.StatusBar = false;
                return false;
            }
            Globals.AMPSAddin.Application.StatusBar = false;
            this.Cursor = Cursors.Default;
            return true;
        }
开发者ID:60East,项目名称:amps-client-excel,代码行数:29,代码来源:ManageSubsForm.cs

示例2: Main

            static void Main()
            {
                Client client = new Client();
                byte[] msg1 = Encoding.ASCII.GetBytes("Pierwsza wiadomosc");
                byte[] msg2 = Encoding.ASCII.GetBytes("Druga wiadomosc");
                byte[] msg3 = Encoding.ASCII.GetBytes("Trzecia wiadomosc");

                if (client.connect()) {
                    Console.WriteLine("Polaczono z serwerem");
                }
                else {
                    Console.WriteLine("Blad przy polaczeniu");
                }
                client.joinServer();
                while (true) { }
                //Application.EnableVisualStyles();
                //Application.SetCompatibleTextRenderingDefault(false);
                //Application.Run(new CoViVo());
            }
开发者ID:gauee,项目名称:CoViVo,代码行数:19,代码来源:Program.cs

示例3: btnTestConnection_Click

 private void btnTestConnection_Click(object sender, EventArgs e)
 {
     // Try to create a new client and logon.
     this.Cursor = Cursors.WaitCursor;
     Globals.AMPSAddin.Application.StatusBar = "Testing connnectivity...";
     try
     {
         Client aClient = new Client(Guid.NewGuid().ToString());
         aClient.connect(getURL());
         aClient.logon();
         this.Cursor = Cursors.Default;
         MessageBox.Show(this, "Test connection succeeded.", "AMPS Connection", MessageBoxButtons.OK, MessageBoxIcon.Information);
         aClient.close();
     }
     catch (AMPSException ae)
     {
         this.Cursor = Cursors.Default;
         MessageBox.Show(this, string.Format("Error connecting to server: {0}{1}",
              ae.Message, ae.InnerException != null ? (" (" + ae.InnerException.Message + ")") : ""),
              "AMPS Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     Globals.AMPSAddin.Application.StatusBar = false;
 }
开发者ID:60East,项目名称:amps-client-excel,代码行数:23,代码来源:ServerForm.cs

示例4: button1_Click

        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            //var topicStore = Globals.AMPSAddin.GetTopicStoreForActiveWorkbook();
            Excel.Range activeCell = Globals.AMPSAddin.Application.ActiveWindow.ActiveCell;

            try
            {
                Excel.Workbook activeWorkbook = Globals.AMPSAddin.Application.ActiveWorkbook;
                var form = new SubscriptionForm(activeWorkbook);
                form.WorksheetRange = Globals.AMPSAddin.Application.ActiveWindow.ActiveSheet.Name+"!"+ activeCell.Address;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    AMPSAddin.ServerDefinition serverDef = Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).Servers[form.ServerName];
                    Client c = new Client(Guid.NewGuid().ToString());
                    c.connect(serverDef.URL);
                    c.logon();
                    string[] worksheetNames = form.WorksheetRange.Split('!');
                    AMPSAddin.SubscriptionDefinition def = new AMPSAddin.SubscriptionDefinition
                    {
                        Name = form.SubscriptionName,
                        ServerName = form.ServerName,
                        Topic = form.Topic,
                        WorksheetRange = form.WorksheetRange,
                        Filter = form.Filter
                    };

                    Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).createOrUpdate(def);

                    ActiveSub.activate(def, c, serverDef.MessageType, Globals.AMPSAddin.Application.ActiveWorkbook);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:60East,项目名称:amps-client-excel,代码行数:37,代码来源:AMPSRibbon.cs

示例5: beginNewTopicSubscription

        private void beginNewTopicSubscription(string url)
        {
            try
            {
                if(_ampsClient!=null)
                {
                    _ampsClient.disconnect();
                }
            }
            catch (Exception )
            {
            }

            try
            {
                _ampsClient = new Client(Guid.NewGuid().ToString());
                _ampsClient.connect(url);
                _ampsClient.logon();
                // make it quick!  Don't want to see the ui lockup.
                _ampsClient.sowAndSubscribe(msg => processTopic(msg), "/AMPS/SOWStats", 1000);
            }
            catch (Exception)
            {
            }
        }
开发者ID:60East,项目名称:amps-client-excel,代码行数:25,代码来源:SubscriptionForm.cs

示例6: ConnectButton_Click

        private void ConnectButton_Click(object sender, EventArgs e)
        {
            string address = textBox1.Text;
            int port = Int32.Parse(textBox2.Text);

            client = new Client(address, port, this);
            if (client.connect())
            {
                connectButton.Enabled = false;
                uploadButton.Enabled = true;
                stepButton.Enabled = true;
            }
        }
开发者ID:EHS-STEM-CODE,项目名称:STEM_code_editor,代码行数:13,代码来源:MainForm.cs

示例7: conectButton_Click

        private void conectButton_Click(object sender, RoutedEventArgs e)
        {
            if (loginTextBox.Text == "")
            {
                txt.Text = "Введите свой логин!";
                if (IsSoundEnabled) playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return;
            }
            if (loginTextBox.Text.Contains<char>(' ') || loginTextBox.Text.Contains<char>('?') || loginTextBox.Text.Contains<char>('#') ||
                loginTextBox.Text.Contains<char>('*') || loginTextBox.Text.Contains<char>('&') || loginTextBox.Text.Contains<char>(';'))
            {
                txt.Text = "Логин не может содержать пробелы и символы & # * ? ;";
                if (IsSoundEnabled) playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return;
            }
            try { port = Convert.ToInt32(portTextBox.Text); }
            catch {
                txt.Text = "Некорректный порт!";
                if (IsSoundEnabled)
                    playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return; }

            try
            {
                string[] temp = ipTextBox.Text.Split('.');
                for (int i = 0; i < 4; i++)
                    ip[i] = Convert.ToByte(temp[i]);
            }
            catch {
                txt.Text = "Некорректный адрес!";
                if (IsSoundEnabled)
                    playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return; }

            if (loginTextBox.Text.Length > 15)
            {
                txt.Text = "Максимальная длина логина 15 символов";
                if (IsSoundEnabled) playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return;
            }

            if (loginTextBox.Text.Length < 3)
            {
                txt.Text = "Минимальная длина логина 3 символа";
                if (IsSoundEnabled) playSound(new Uri(@"sounds\\error.mp3", UriKind.Relative));
                return;
            }

            client = new Client(loginTextBox.Text, ip, port, this, m);
            client.connectSuccess += new EventHandler(client_connectSuccess);
            client.connect();
        }
开发者ID:Retivykh-Serg,项目名称:Dixit,代码行数:52,代码来源:Connection.xaml.cs


注:本文中的Client.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。