コード例 #1
0
ファイル: Client.cs プロジェクト: ppawlinski/GPSTCPServer
        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));
        }
コード例 #2
0
 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();
 }
コード例 #3
0
 private void StopReceive()
 {
     if (bkgReceiveBackground.IsBusy)
     {
         bkgReceiveBackground.CancelAsync();
         //
         bkgReceiveBackground.Dispose();
     }
     //Fecha stream do client
     if (TCP.Connected)
     {
         TCP.GetStream().Close();
     }
     //Fecha canal
     networkStream.Close();
 }
コード例 #4
0
 protected override void SendMessageJob(QueuedSendPacket nPacket)
 {
     TCP.GetStream().Write(nPacket.Dgram, 0, nPacket.Dgram.Length);
 }
コード例 #5
0
ファイル: Client.cs プロジェクト: ppawlinski/GPSTCPServer
 public async static void Send(string message)
 {
     await TCP.GetStream().WriteAsync(Encoding.UTF8.GetBytes(message));
 }