public static void CloseReceiveClient() { // Release the socket. ReceiveClient.Shutdown(SocketShutdown.Both); ReceiveClient.Close(); ReceiveClientConnected = false; }
// Use this for initialization void Start() { TcpClient client = new TcpClient(); client.Connect(SERVER_IP, 4747); stream = client.GetStream(); unitAction = GetComponent <BaseAction_AI_player>(); receive = new ReceiveClient(client); Thread thread = new Thread(receive.receiveThread); thread.Start(); }
/// <summary> /// initializes an instance of <see cref="TmiConnection"/> /// </summary> /// <exception cref="InvalidOperationException">if invalid command handlers are defined on the used subclass</exception> public TmiConnection() { receiver = new ReceiveClient(this); sender = new SendClient(this); status = new Status(this); Parser = new TmiMessageParser(); pingTimer = new System.Timers.Timer { AutoReset = true, Enabled = false, Interval = 4 * 60 * 1000 }; pingTimer.Elapsed += PingTimerOnElapsed; RegisterCommands(); }
/// <summary> /// 终止UDPManager的线程及各类调用 /// </summary> public void QuitManager() { try { sendThread.Interrupt(); reciveThread.Interrupt(); sendThread.Abort(); reciveThread.Abort(); Sendclient.Close(); ReceiveClient.Close(); } catch (Exception e) { ManagerLog(e.ToString()); } }
public SharingController() { UsersConnected = new BindingList <string>(); ReceivedSamples = new BindingList <ReceivedSample>(); Random random = new Random(); var randomNumber = random.Next(0, 100); UserName = Environment.UserName + randomNumber; jsonSerializer = new JavaScriptSerializer(); // Initialize ReceiveClient receiveClient = new ReceiveClient(); receiveClient.NewNames += new GotNames(receiveClient_NewNamesReceived); receiveClient.ReceiveMsg += new ReceviedMessage(receiveClient_ReceiveMessage); }
public void SendConsumptionForecast(long contractId) { Trace.WriteLine("SendConsumptionForecast"); try { DataManager dataMan = new DataManager(); electricityProfile ep = new electricityProfile(); Random rn = new Random(); ContractData contractData = dataMan.GetContractData(contractId); ep.areaId = contractData.AreaId.ToString(); ep.amount = rn.Next(100, 200).ToString(); ep.contractId = contractData.ContractId.ToString(); ep.dateStart = contractData.StartDate; ep.dateEnd = DateTime.Now; ep.fromId = "T1ES1"; //send to first krado ep.toId = "T1RK1"; try { ep.messageId = dataMan.SaveComposedMessage(ep).ToString(); t1rk1Client = new KradoServiceSoapClient(); balanceInvoice bi = t1rk1Client.presumableLoadProfile(ep); this.ReceiveBalanceInvoice(bi); } catch (Exception rk1Exc) { Trace.WriteLine("Error sending consumption forecast to T1RK1: " + rk1Exc.Message); } //send to second krado ep.toId = "T1RK2"; try { ep.messageId = dataMan.SaveComposedMessage(ep).ToString(); t1rk2Client = new ReceiveClient(); string tmp = t1rk2Client.ReceiveCfFromEs("some piparkoogid from T1ES1"); } catch (Exception rk2Exc) { Trace.WriteLine("Error sending consumption forecast to T1RK2: " + rk2Exc.Message); } } catch (Exception scfExc) { Trace.WriteLine("Error sending consumption forecast: " + scfExc.Message); } }