/// <summary> /// düşen datayı yakalayacan metot /// </summary> /// <param name="server"></param> /// <param name="e"></param> public override void SessionReceive(IServer server, SessionReceiveEventArgs e) { try { TcpResponseModel tcpResponseModel = new TcpResponseModel() { Result = "OK" }; BeetleX.Buffers.PipeStream pipeStream = e.Stream.ToPipeStream(); using (MemoryStream memoryStream = new MemoryStream(pipeStream.FirstBuffer.Data)) //pipeStream1.LastBuffer.Data using (StreamReader reader = new StreamReader(memoryStream)) { var data = reader.ReadToEnd(); if (!string.IsNullOrEmpty(data)) { TcpInit.GetIntance().TcpDataReceived(data, null); } pipeStream.Write(@"{""result"":""OK""}!"); e.Session.Stream.Flush(); base.SessionReceive(server, e); } } catch (Exception ex) { Console.WriteLine($"{ex + "TcpConsumer/SessionReceive"}"); } }
static void Main(string[] args) { TcpInit.GetIntance().StartConsume(); TcpInit.GetIntance().DataReceived += Program_DataReceived; Console.ReadLine(); }