/// <summary> /// the tcp have Losted i will deal here /// </summary> void nowSocket_OnTcpConnectionLosted() { DialogResult yourResult = MessageBox.Show("连接中断!是否关闭该窗口", myIpEp.Address.ToString(), MessageBoxButtons.AbortRetryIgnore); if (yourResult == DialogResult.Retry) { if (nowSocket.Connect()) { } else { pictureBox_headHeart.Image = ((AutoRunner)(this.Parent.Parent.Parent.Parent)).imageListForButton.Images[2]; this.Text += " DisConnect"; MessageBox.Show(nowSocket.ErroerMessage, "STOP"); } } else if (yourResult == DialogResult.Abort) { //已知风险,重复关闭 this.Close(); } else { pictureBox_headHeart.Image = ((AutoRunner)(this.Parent.Parent.Parent.Parent)).imageListForButton.Images[2]; this.Text += " DisConnect"; } }
private void myDirectionalTestForDevEpAdd_Load(object sender, EventArgs e) { isTest = false; mywaitTime = 10; myTimeOut = setTimeOut; comboBox_waitTime.SelectedIndex = 0; //class nowVaneConfigRequestData = new myVaneConfigRequestData(); myBeatTimer.Interval = 20000; myBeatTimer.Tick += new EventHandler(myBeatTimer_Tick); //set the from name this.Text += (" " + myIpEp.Address.ToString()); nowSocket = new MyTcpClient(myIpEp, 500); if (!nowSocket.IsTcpClientConnected) { if (nowSocket.Connect()) { nowSocket.OnReceiveData += new MyTcpClient.delegateReceiveData(nowSocket_nowReceiveData); nowSocket.OnTcpConnectionLosted += new MyTcpClient.ConnectionLosted(nowSocket_OnTcpConnectionLosted); myBeatTimer.Enabled = true; addMessage("coonect success"); } else { MessageBox.Show(nowSocket.ErroerMessage); this.Close(); } } }
void Start() { Application.quitting += client.DisConnect; matchingText.text = text; try { client.Connect(); } catch (Exception e) { Debug.LogError(e); SceneChangeManager.ChangeTitleScene(); return; } MatchType?matchType = null; matchingClient = new MatchingClient(client, async data => { if (data.MatchingDataType == MatchingDataType.MatchedData) { matchingText.text = "マッチしました。"; if (data.MatchType == MatchType.Host) { await WaitStageSelect(data.MatchType.Value); } else { matchingText.text = "Hostがステージを選択中です。"; } matchType = data.MatchType; } else { if (data.StageKind == null) { return; } await WaitGamePlay(data.StageKind.Value, matchType.Value); matchingText.text = "ステージが決定されました。ゲームを開始します。"; } }); cancel.MatchingCancelEvent += (sender, args) => { client.DisConnect(); SceneChangeManager.ChangeTitleScene(); matchingClient.MatchingDataObserver.OnError(new OperationCanceledException()); }; }
void Start() { client.Connect(); client.DisConnected += () => Debug.Log("TCP切断"); matchingClient = new MatchingClient(client, data => { if (data.MatchingDataType == MatchingDataType.MatchedData) { Debug.Log("マッチ"); Debug.Log(data.MatchType); } }); }
private void MyVaneConfig_Load(object sender, EventArgs e) { //cantrol and vaule splitContainer_orderForm.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; myMaxLine = ((AutoRunner)(this.Parent.Parent.Parent.Parent)).MaxLine; cb_verUpgradeRequest_verType.SelectedIndex = 0; isMyAlive = true; this.Activate(); //class nowVaneConfigRequestData = new myVaneConfigRequestData(); myBeatTimer.Interval = 20000; myBeatTimer.Tick += new EventHandler(myBeatTimer_Tick); //test Thread myThread = new Thread(new ParameterizedThreadStart(newTestThread)); myThread.IsBackground = true; myThread.Start(""); //set the from name this.Text += (" " + myIpEp.Address.ToString()); nowSocket = new MyTcpClient(myIpEp, 500); if (!nowSocket.IsTcpClientConnected) { if (nowSocket.Connect()) { nowSocket.OnReceiveData += new MyTcpClient.delegateReceiveData(nowSocket_nowReceiveData); nowSocket.OnTcpConnectionLosted += new MyTcpClient.ConnectionLosted(nowSocket_OnTcpConnectionLosted); myBeatTimer.Enabled = true; MyPutInKey keyWindow = new MyPutInKey(); keyWindow.Owner = this; keyWindow.StartPosition = FormStartPosition.CenterParent; keyWindow.ShowDialog(); { if (isKeyNeed) { //MessageBox.Show(myGwKey); doConfiguration(myGwKey); } else { MessageBox.Show("NOT FIND THE KEY"); } } } else { MessageBox.Show(nowSocket.ErroerMessage); this.Close(); } } }
/// <summary> /// the tcp have Losted i will deal here /// </summary> void nowSocket_OnTcpConnectionLosted() { addMessage("连接中断"); Found: if (nowSocket.Connect()) { addMessage("重连成功"); if (isTest) { reStartTest(); addMessage("继续任务"); } } else { addMessage(nowSocket.ErroerMessage); addMessage("重连失败"); goto Found; } /* * DialogResult yourResult = MessageBox.Show("连接中断!是否关闭该窗口", "stop", MessageBoxButtons.AbortRetryIgnore); * if (yourResult == DialogResult.Retry) * { * if (nowSocket.connectClient()) * { * addMessage("重连成功"); * if (isTest) * { * reStartTest(); * addMessage("继续任务"); * } * } * else * { * MessageBox.Show(nowSocket.myErroerMessage, "STOP"); * } * } * else if (yourResult == DialogResult.Abort) * { * this.Close(); * } * else * { * //do nothing * } */ }
void Awake() { var myTcpClient1 = new MyTcpClient("localhost", 3000); var myTcpClient2 = new MyTcpClient("localhost", 3000); myTcpClient1.Connect(); myTcpClient2.Connect(); matchingServer1 = new MatchingClient(myTcpClient1, data => { if (data.MatchingDataType == MatchingDataType.MatchedData) { if (data.MatchType == MatchType.Host) { CreateGameSignaling(myTcpClient1, data.MatchType.Value); } } else if (data.MatchingDataType == MatchingDataType.StageDeterminedData) { CreateGameSignaling(myTcpClient1, MatchType.Client); } }); matchingServer2 = new MatchingClient(myTcpClient2, data => { if (data.MatchingDataType == MatchingDataType.MatchedData) { if (data.MatchType == MatchType.Host) { CreateGameSignaling(myTcpClient2, data.MatchType.Value); } } else if (data.MatchingDataType == MatchingDataType.StageDeterminedData) { CreateGameSignaling(myTcpClient2, MatchType.Client); } }); }
private static string SendData(byte[] bits) { return(MyTcpClient.Connect("127.0.0.1", bits)); }
public bool Connect(string host, int port) { return(_tcp.Connect(host, port)); }
public bool ExecutionDeviceConnect() { isConnect = myTcpClient.Connect(); return(isConnect); }