/// <summary> /// コンストラクタ /// </summary> /// <param name="localPort">自分のポート</param> public RemoteHost(int localPort, DebugWindow debugwindow, TerminalConnection.TerminalConnection TC) { try { this.UP_Cliant = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort); this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); this.id = localPort; this.CTS = new CancellationTokenSource(); this.mytask = new Task(() => this.Main_Task(), CTS.Token); this.mytask.Start(); this.fpsa = new FPSAdjuster.FPSAdjuster(); this.debugwindow = debugwindow; this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します"; this.TC = TC; } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
/// <summary> /// コンストラクタ /// </summary> /// <param name="localPort">自分のポート</param> public RemoteHost(int localPort, DebugWindow debugwindow/*, TerminalConnection.TerminalConnection TC*/) { try { this.UP_Cliant = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(localPort); this.UP_Encoder = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); this.UP_Decoder = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); this.id = localPort; this.CTS = new CancellationTokenSource(); this.mytask = new Task(() => this.Main_Task(), CTS.Token); this.mytask.Start(); this.fpsa = new FPSAdjuster.FPSAdjuster(); this.debugwindow = debugwindow; this.debugwindow.DebugLog = "[Port:" + localPort.ToString() + "]受信を開始します"; //this.TC = TC; } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
/// <summary> /// 接続を切断します。 /// </summary> public void disconnect() { try { this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]切断します."; UP_Cliant.Close(); this.data = null; if (this.connect_host != null) { this.connect_host.connect_host = null; this.connect_host = null; } CTS.Cancel(); isConnected = false; this.UP_Encoder = null; this.UP_Decoder = null; this.UP_Cliant = null; this.DataReceived = null; } catch (Exception ex) { Console.WriteLine(ex.Message + "接続の切断に失敗しました。"); } finally { } }
public void Close() { this.udp_client.Close(); this.udp_client = null; Thread.Sleep(100); this.Close_add(); }
private void Connect() { this.Connect_add(); switch (this.mode) { case MODE.non: this.mode = SETTINGS.MyInfo.Mode; Connect(); break; case MODE.Sender: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.serverIP, this.remotePort, this.myPort); Connect_Sender_add(); break; case MODE.Receiver: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.serverIP, this.remotePort, this.myPort); Connect_Receiver_add(); break; case MODE.Both: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.serverIP, this.remotePort, this.myPort); Connect_Both_add(); break; case MODE.DirectConnect: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.serverIP, this.remotePort, this.myPort); Connect_Direct_add(); break; default: break; } }
public void Close() { this.udp_client.Close(); this.udp_client = null; Thread.Sleep(100); this.Close_add(); }
public ClientHost(int Port) { this.clientstatus = new ClientStatus(); this.clientstatus.ServerPort = Port; this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(Port); this.client.DataReceived += client_DataReceived_Init; }
public RemoteHostServer() { try { client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); this.LstPort = new List <int>(); mytask = new Task(() => this.MAIN_TASK()); mytask.Start(); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { #region create remotehost servers list and one remotehost server this.List_remotehost = new List <RemoteHost>(); #endregion } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
/// <summary> /// サーバがアクセスされるまで待機し、アクセスされた場合そのメッセージを検査し、その情報に従って /// ポートを割り振る、もしくは終了します。 /// </summary> /// <returns></returns> private void update(ref int Port, ref bool isConnect) { try { this.client.Close(); this.client = null; Thread.Sleep(100); this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort); this.debugwindow.DebugLog = "[RemoteHostServer]操作受付を開始します.ポート:" + this.server_port; while (true) { if (this.client.Received_Data != null) { dec.Source = this.client.Received_Data; break; } Thread.Sleep(10); } Thread.Sleep(100); switch (dec.get_int()) { case Definitions.CONNECTION_DEMANDS: isConnect = true; break; case Definitions.CONNECTION_END: isConnect = false; break; default: this.debugwindow.DebugLog = "要求された信号に対応するコマンドが存在しません。リモートホスト側のコネクトの設定を確認してください。"; break; } if (isConnect) { this.connect(ref Port); } else { this.disconnect(dec.get_int()); try { this.terminalconnection.Tcp_Send(); } catch (Exception ex) { debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message; } } }catch (Exception ex) { MessageBox.Show(ex.Message + "ポートを割り振るサーバのアップデートでエラーが発生しました。"); } }
public void Close() { if (IsClosed == false) { this.udp_client.Close(); this.udp_client = null; Thread.Sleep(100); this.Close_add(); this.IsClosed = true; } }
public static void DisconnectByUserPort(int SenderUserPort, int ReceiverUserPort, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); enc += (int)14; enc += SenderUserPort; enc += ReceiverUserPort; client.Send(enc.data); client.Close(); }
public static void Connect(int SenderID, int ReceiverID, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); enc += (int)5; enc += SenderID; enc += ReceiverID; client.Send(enc.data); client.Close(); }
public static void Disconnect(int SenderID, int ReceiverID, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); enc += (int)6; enc += SenderID; enc += ReceiverID; client.Send(enc.data); client.Close(); }
public static void ConnectByUserPort(int SenderUserPort, int ReceiverUserPort, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); enc += (int)13; enc += SenderUserPort; enc += ReceiverUserPort; client.Send(enc.data); client.Close(); }
public void Close() { if (IsClosed == false) { this.udp_client.Close(); this.udp_client = null; Thread.Sleep(100); this.Close_add(); this.IsClosed = true; } }
public void Close() { foreach (var p in this.List_ClientHosts) { p.Close(); } this.client.DataReceived -= client_DataReceived; this.client.Close(); this.client = null; }
public MainServer() { this.Init_Classes(); this.Load_Settings(); this.CurrentPort = int.Parse(this.settings.StartPort); this.StartPort = this.CurrentPort; this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(int.Parse(this.settings.PortNum)); this.client.DataReceived += client_DataReceived; }
public MainServer() { this.Init_Classes(); this.Load_Settings(); this.CurrentPort = int.Parse(this.settings.StartPort); this.StartPort = this.CurrentPort; this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(int.Parse(this.settings.PortNum)); this.client.DataReceived += client_DataReceived; }
public void Setup(MODE mode) { this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.remoteIP, this.serverPort, this.myPort); this.mode = mode; this.Connect(); }
private void Connect() { this.Connect_add(); switch (this.mode) { case MODE.non: this.mode = SETTINGS.MyInfo.Mode; Connect(); break; case MODE.Sender: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.remoteIP, this.remotePort, this.myPort); Connect_Sender_add(); break; case MODE.Receiver: this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.remoteIP, this.remotePort, this.myPort); Connect_Receiver_add(); break; default: break; } }
public RemoteHostServer() { try { client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); this.LstPort = new List<int>(); mytask = new Task(() => this.MAIN_TASK()); mytask.Start(); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { #region create remotehost servers list and one remotehost server this.List_remotehost = new List<RemoteHost>(); #endregion } catch(Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
/// <summary> /// サーバがアクセスされるまで待機し、アクセスされた場合そのメッセージを検査し、その情報に従って /// ポートを割り振る、もしくは終了します。 /// </summary> /// <returns></returns> private void update(ref int Port, ref bool isConnect) { try { this.client.Close(); this.client = null; Thread.Sleep(100); this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort); this.debugwindow.DebugLog = "[RemoteHostServer]操作受付を開始します.ポート:" + this.server_port; while (true) { if (this.client.Received_Data != null) { dec.Source = this.client.Received_Data; break; } Thread.Sleep(10); } Thread.Sleep(100); switch (dec.get_int()) { case Definitions.CONNECTION_DEMANDS: isConnect = true; break; case Definitions.CONNECTION_END: isConnect = false; break; default: this.debugwindow.DebugLog = "要求された信号に対応するコマンドが存在しません。リモートホスト側のコネクトの設定を確認してください。"; break; } if (isConnect) { this.connect(ref Port); } else { this.disconnect(dec.get_int()); try { this.terminalconnection.Tcp_Send(); } catch (Exception ex) { debugwindow.DebugLog = "[" + this.ToString() + "]" + ex.Message; } } }catch(Exception ex) { MessageBox.Show( ex.Message + "ポートを割り振るサーバのアップデートでエラーが発生しました。"); } }
public void Close() { foreach (var p in this.List_ClientHosts) { p.Close(); } this.client.DataReceived -= client_DataReceived; this.client.Close(); this.client = null; }
public void Setup(MODE mode) { this.udp_client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(this.serverIP, this.serverPort, this.myPort); this.mode = mode; this.Connect(); }
/// <summary> /// 接続を切断します。 /// </summary> public void disconnect() { try { this.debugwindow.DebugLog = "[Port:" + this.ID.ToString() + "]切断します."; UP_Cliant.Close(); this.data = null; if (this.connect_host != null) { this.connect_host.connect_host = null; this.connect_host = null; } CTS.Cancel(); isConnected = false; this.UP_Encoder = null; this.UP_Decoder = null; this.UP_Cliant = null; this.DataReceived = null; } catch (Exception ex) { Console.WriteLine(ex.Message + "接続の切断に失敗しました。"); } finally { } }
public RemoteHostServer() { try { this.Eventer = new TerminalConnectionSettings.CommandEventer(); client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(myPort); this.remoteOperator = new RemoteOperater(client); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { this.enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); this.dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); this.LstPort = new List<int>(); } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } try { #region create remotehost servers list and one remotehost server this.List_remotehost = new List<RemoteHost>(); #endregion client.DataReceived += client_DataReceived; } catch (Exception ex) { while (true) { myDialog dialog = new myDialog(ex.Message); if (dialog.ShowDialog() == true) { break; } } } }
public static void Connect(int SenderID, int ReceiverID, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); Udp_Send(client, new TerminalConnectionSettings.TerminalProtocols.Connect(SenderID, ReceiverID)); client.Close(); }
public static void DisconnectByClientName(string SenderClientName, string ReceiverClientName, string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); Udp_Send(client, new TerminalConnectionSettings.TerminalProtocols.DisConnectByName(SenderClientName, ReceiverClientName)); client.Close(); }
public void SetupUDP() { try { if (!this.IsConnectionSetupped) { var remoteport = this.window.connectionsetting.IsConnectionLocal ? this.window.connectionsetting.localport : this.window.connectionsetting.remoteport; var remoteip = this.window.connectionsetting.IsConnectionLocal ? "127.0.0.1" : this.window.connectionsetting.remoteIP; this.client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(remoteip, int.Parse(remoteport), 18000); this.client.DataReceived += client_DataReceived; //ちょっとやそっとのエラーでもがんがん復活するスタイル this.client.IsRecast = true; this.IsConnectionSetupped = true; this.Udp_Send(new TerminalConnectionSettings.TerminalProtocols.DemmandInfo()); this.ConfirmCIPCServer(); } } catch { throw; } }
public static void TurnOnSyncConnect(string RemoteIP, int RemotePort, int myPort) { UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT client = new UDP_PACKETS_CLIANT.UDP_PACKETS_CLIANT(RemoteIP, RemotePort, myPort); Udp_Send(client, new TerminalConnectionSettings.TerminalProtocols.TurnOnSyncConnect()); client.Close(); }