private void button2_Click(object sender, EventArgs e) { try { if (_ClientRdet == null) { _ClientRdet = new ClientSocket(_logClient); } //this.lbcPackage1.Items.Add("Connect 127.0.0.1:5000 ..."); _ClientRdet.Connect(this.tbServerIP.Text, Convert.ToInt32(this.tbServerPort.Text)); if (_ClientRdet.IsConnected) { //this.lbcPackage1.Items.Add("Connect 127.0.0.1:5000 Success!"); MessageBox.Show("Connect " + this.tbServerIP.Text + ":" + tbPort.Text + " Success!"); } else { //this.lbcPackage1.Items.Add("Connect 127.0.0.1:5000 failure!"); MessageBox.Show("Connect " + this.tbServerIP.Text + ":" + tbPort.Text + " Failure!"); } } finally { _ClientRdet.DisConnect(false); } }
int ConnectGateServer(Message _msg) { Debug.Log("connect gate server start"); GameManager.Instance.GamePause(); m_Net.DisConnect(); ServerInfo gateserver = ServerInfo.Parser.ParseFrom(_msg.m_data); if (m_Net.ConnectServer(gateserver.MIp, gateserver.MPort) < 0) { return(-1); } MsgHead msg_head = new MsgHead { m_usrid = _msg.m_usrid }; byte[] data = new byte[16]; msg_head.EnCode(data, 0); m_Net.Send(data, 16); UIManager.Instance.ClosePanel("LoginPanel"); UIManager.Instance.ShowPanel("PanelMain"); GameManager.Instance.GameStart(); Debug.Log("connect gate server end"); return(0); }
public void OnDestroy() { Unload(); m_clientSocket.DisConnect(); m_clientSocket.RemoveStateEvent(OnSocketStateEvt); m_clientSocket.RemovePacketDistributeEvent(OnPacketDistributeEvt); Debug.Log("~NetworkManager was destroy"); }
private void button2_Click(object sender, EventArgs e) { this.CreateClientSocket(); string sServerIP = tbServerIP.Text; int iServerPort = Convert.ToInt32(tbServerPort.Text); _ClientSocket.Connect(sServerIP, iServerPort, _logClient); if (_ClientSocket.IsConnected()) { //this.lbcPackage1.Items.Add("Connect 127.0.0.1:5000 Success!"); MessageBox.Show("Connect " + sServerIP + ":" + iServerPort.ToString() + " Success!"); } else { //this.lbcPackage1.Items.Add("Connect 127.0.0.1:5000 failure!"); MessageBox.Show("Connect " + sServerIP + ":" + iServerPort.ToString() + " Failure!"); } _ClientSocket.DisConnect(false); }
public void ExitGame() { MsgHead msg = new MsgHead(); msg.m_type = (uint)EventType.EXIT; msg.m_len = 0; msg.m_usrid = mainPlayerID; msg.m_errID = 0; byte[] temp = new byte[MsgHead.headsize()]; msg.EnCode(temp, 0); m_Net.Send(temp, MsgHead.headsize(), 0); m_Net.DisConnect(); Invoke(nameof(Application.Quit), 1f); }
private void btClientSend_Click(object sender, EventArgs e) { int count = Convert.ToInt32(this.textBox1.Text); for (int i = 0; i < count; i++) { _ClientSocket = new ClientSocket(_ClientLog); _ClientSocket.Connect("127.0.0.1", 7000, _ClientLog); try { string sMsg = "No:" + i.ToString() + "<><PacketType=1%Souce=150.245.176.146|1033%Destination=127.0.0.1|6000><Command type=8%CommandGUID=919c7150002e4294a33bd638951ce1ff><Paramname=AccessionNumber%ParamValue=><Paramname=ModalityName%ParamValue=James><Paramname=OperatorName%ParamValue=><Paramname=PatientID%ParamValue=U100203303><Paramname=Performed_enddt%ParamValue=2005-07-29 10:16:14><Paramname=Performed_startdt%ParamValue=2005-07-29 10:16:14> "; this.listBox1.Items.Add(sMsg); sMsg = _ClientSocket.SendMsg(sMsg); this.listBox2.Items.Add(sMsg); } finally { _ClientSocket.DisConnect(false); _ClientSocket = null; } } }
private string SendMsgToServer(CommandSendData csd) { try { _ClientSocket.Connect(); PacketHead ph = csd.PacketHead; //ph.SourceIP = _ClientSocket.LocalIP; //ph.SourcePort = _ClientSocket.LocalPort; csd.PacketHead = ph; string result = _ClientSocket.SendMsg(csd.EncodePackage()); _ClientSocket.DisConnect(false); return(result); } catch (Exception ex) { Program.Log.Write(ex); return(null); } }
private void OnDisable() { #if UNITY_EDITOR client.DisConnect(); #endif }
public void OffLine() { client.DisConnect(); }
private void SendCommand2Server(RdetOutChannel ch, DataSet ds) { foreach (DataRow dr in ds.Tables[0].Rows) { // build command if (!ds.Tables[0].Columns.Contains("Command")) { Program.Log.Write(LogType.Error, "Configuration File error!Cannot find column 'Command'!\r\n" + "channel name:" + ch.ChannelName + "\r\n"); return; //throw new Exception(""); } try { CmdReqBase request = null; if (CommandToken.IsNewPatient(dr["Command"].ToString())) { request = BuildCmdReqNewPatient(ch, dr); } else if (CommandToken.IsUpdatePatient(dr["Command"].ToString())) { request = BuildCmdReqUpdatePatient(ch, dr); } else if (CommandToken.IsNewImage(Convert.ToString(dr["Command"]))) { request = BuildCmdReqNewImage(ch, dr); } if (request == null) { Program.Log.Write("Invalid DataRow! Command=" + dr["Command"].ToString() + " \r\n"); continue; } // Send Command CmdRespBase resp; if (Program.bStandalone) { resp = new CmdRespBase(); resp.AddParameter(CommandToken.StudyInstanceUID, "StudyInstenceUID001"); resp.ErrorCode = "0"; } else { resp = _ClientSocket.SendCommand(request); } _ClientSocket.DisConnect(false); if (resp == null) { Program.Log.Write("There is no correct response or no response data to request ! \r\n"); continue; } if (Convert.ToInt32(resp.ErrorCode) == 0) { if (OnDataDischarge != null) { this.OnDataDischarge(new string[] { Convert.ToString(dr["Data_ID"]) }); } //Write StudyinstanceUID if (CommandToken.IsNewPatient(request.Command)) { UpdateStudyInstanceUID(Convert.ToString(dr["Data_ID"]), resp.GetParamValue(CommandToken.StudyInstanceUID), _fStudyInstanceUID); } } else { RdetError Err = RdetErrorMgt.GetRdetError(Convert.ToInt32(resp.ErrorCode.Trim())); Program.Log.Write(LogType.Error, "------------Error Exist! ----------------------------------------\r\n" + "ErrorCode=" + Err.Code.ToString() + "\r\n" + "Error Description: " + Err.ErrorDescription + "\r\n" + "Error Resolution : " + Err.ErrorDescription + "\r\n" + "----------------------------------------------------------------\r\n", true); } } catch (Exception ex) { Program.Log.Write(LogType.Error, "Unknow Error:" + ex.Message + "\r\n" + "channel Name:" + ch.ChannelName + "\r\n"); } } }
public void DisConnect() { _client.DisConnect(); }