private async static Task <string> getUserInput(byte[] buffer) { await TCP.GetStream().ReadAsync(buffer, 0, buffer.Length); //await TCP.GetStream().ReadAsync(new byte[10]); return(Encoding.UTF8.GetString(buffer).Trim().Replace("\0", String.Empty)); }
public void StartReceive() { //Cria fluxo de conexão (stream) networkStream = TCP.GetStream(); // bkgReceiveBackground de recepçao que é chamado por uma rotina sincrona. bkgReceiveBackground = new BackgroundWorker(); bkgReceiveBackground.WorkerReportsProgress = true; bkgReceiveBackground.WorkerSupportsCancellation = true; bkgReceiveBackground.DoWork += new DoWorkEventHandler(bgwReceiveBackground_DoWork); bkgReceiveBackground.ProgressChanged += new ProgressChangedEventHandler(bgwReceiveBackground_ProgressChanged); bkgReceiveBackground.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwReceiveBackground_RunWorkerCompleted); //Inicia operçao em background bkgReceiveBackground.RunWorkerAsync(); }
private void StopReceive() { if (bkgReceiveBackground.IsBusy) { bkgReceiveBackground.CancelAsync(); // bkgReceiveBackground.Dispose(); } //Fecha stream do client if (TCP.Connected) { TCP.GetStream().Close(); } //Fecha canal networkStream.Close(); }
protected override void SendMessageJob(QueuedSendPacket nPacket) { TCP.GetStream().Write(nPacket.Dgram, 0, nPacket.Dgram.Length); }
public async static void Send(string message) { await TCP.GetStream().WriteAsync(Encoding.UTF8.GetBytes(message)); }