Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Brayan Sarmiento
API-Gateway-CHEC
Commits
70debb0f
Commit
70debb0f
authored
Jun 23, 2024
by
Brayan Sarmiento
Browse files
Cambios en el metodo Send para enviar info al posbc
parent
fedb0e36
Changes
1
Hide whitespace changes
Inline
Side-by-side
gatewayGK/POSBC/ClienteServidorPOSBC.cs
View file @
70debb0f
...
...
@@ -76,20 +76,40 @@ public class ClienteServidorPOSBC(string ip, int pto)
// Usar un MemoryStream para manejar datos de longitud arbitraria
using
(
var
ms
=
new
System
.
IO
.
MemoryStream
(
1024
))
{
while
((
bytesRead
=
_socket
.
Receive
(
buffer
))
>
0
)
{
ms
.
Write
(
buffer
,
0
,
bytesRead
);
totalBytesRead
+=
bytesRead
;
// Tiempo de espera adicional en milisegundos
int
timeout
=
10000
;
// 10 segundos
// Romper el ciclo si se ha leído todo el mensaje
if
(
_socket
.
Available
==
0
)
break
;
while
(
true
)
{
Log
.
Information
(
"Esperamos 10 segundos para ingresar al posbc..."
);
// Esperar a que haya datos disponibles para recibir o que se alcance el tiempo de espera
if
(
_socket
.
Poll
(
timeout
*
1000
,
SelectMode
.
SelectRead
))
{
Log
.
Information
(
"Ingresamos a leer bytes del servidor despues 10 segundos"
);
bytesRead
=
_socket
.
Receive
(
buffer
);
if
(
bytesRead
>
0
)
{
ms
.
Write
(
buffer
,
0
,
bytesRead
);
totalBytesRead
+=
bytesRead
;
}
else
{
// No hay más datos para leer
break
;
}
}
else
{
// Se ha alcanzado el tiempo de espera sin recibir más datos
break
;
}
}
// Obtener todos los datos recibidos como un arreglo de bytes
bufferEntrada
=
ms
.
ToArray
();
}
_contadorMensajesRecibidos
++;
Log
.
Information
(
"Sesion donde termina la cantidad de información que recibe del POSBC"
);
Log
.
Information
(
"Respuesta #{contador} de POSBC {ip}"
,
_contadorMensajesRecibidos
,
_ip
);
Log
.
Debug
(
"Mensaje - {msj}"
,
_contadorMensajesRecibidos
,
_ip
,
Encoding
.
UTF8
.
GetString
(
bufferEntrada
));
Log
.
Debug
(
Util
.
DetalleMensajes
(
bufferEntrada
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment