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
7be3dce9
Commit
7be3dce9
authored
Jun 11, 2024
by
Brayan Sarmiento
Browse files
Ciclo completo de inicio de sesion
En este commit se realizo el ciclo completo de chec para iniciar sesion.
parent
dbe4bfb5
Changes
3
Show whitespace changes
Inline
Side-by-side
gatewayGK/POSBC/InitializeRequestPosbcCmd.cs
View file @
7be3dce9
...
...
@@ -51,11 +51,15 @@ namespace gatewayGK.POSBC
socket
.
Connect
(
endPoint
);
Log
.
Information
(
"Conectandose al servidor POSBC"
);
// Enviar los datos
socket
.
Send
(
bufferRecibido
,
SocketFlags
.
None
);
Log
.
Information
(
$"Buffer de entrada enviado al servidor POSBC
{
bufferRecibido
}
"
);
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
// Configurar timeout para el socket (por ejemplo, 5 segundos)
socket
.
ReceiveTimeout
=
10000
;
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
List
<
byte
>
receivedBytes
=
new
List
<
byte
>();
byte
[]
bufferSalida
=
new
byte
[
1024
];
...
...
@@ -63,7 +67,19 @@ namespace gatewayGK.POSBC
while
(
true
)
{
int
bytesLeidos
=
0
;
try
{
bytesLeidos
=
socket
.
Receive
(
bufferSalida
,
0
,
bufferSalida
.
Length
,
SocketFlags
.
None
);
}
catch
(
SocketException
ex
)
{
if
(
ex
.
SocketErrorCode
==
SocketError
.
TimedOut
)
{
Log
.
Information
(
"Tiempo de espera agotado. No se recibieron más datos."
);
break
;
}
}
//Coloque 1 Porque POSBC si no tiene mas bytes que mandar, manda 1 y no 0
if
(
bytesLeidos
==
0
||
bytesLeidos
==
1
)
{
...
...
@@ -84,24 +100,6 @@ namespace gatewayGK.POSBC
string
result
=
Encoding
.
UTF8
.
GetString
(
data
);
Entorno
<
EntornoPOSBC
>.
Instancia
.
get
().
BufferSalida
=
data
;
//buffer de salida del POSBC
//byte[] bufferSalida = new byte[3048];
//int bytesLeidos = 0;
//bytesLeidos = socket.Receive(bufferSalida, bytesLeidos, bufferSalida.Length, SocketFlags.None);
//string pasarXml = Encoding.UTF8.GetString(bufferSalida, 0, bytesLeidos);
//Log.Information($"Xml Armado {pasarXml}");
//byte[] datosRecibidos = new byte[bytesLeidos];
//// Copiar los datos recibidos al nuevo array
//Array.Copy(bufferSalida, datosRecibidos, bytesLeidos);
//// Convertir los datos recibidos a una cadena
//bufferSalida = datosRecibidos;
////string response = Encoding.UTF8.GetString(buffer, 0, bytesReceived);
//Log.Information($"buffer de salida recibido del POSBC {bufferSalida}");
//Entorno<EntornoPOSBC>.Instancia.get().BufferSalida = bufferSalida;
// Cerrar el socket
socket
.
Shutdown
(
SocketShutdown
.
Both
);
socket
.
Close
();
...
...
gatewayGK/POSBC/QueryStatusRequestPosbcCmd.cs
View file @
7be3dce9
...
...
@@ -50,8 +50,10 @@ namespace gatewayGK.POSBC
// Enviar los datos
socket
.
Send
(
bufferRecibido
,
SocketFlags
.
None
);
Log
.
Information
(
$"Buffer de entrada enviado al servidor POSBC
{
bufferRecibido
}
"
);
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
// Configurar timeout para el socket (por ejemplo, 5 segundos)
socket
.
ReceiveTimeout
=
5000
;
// en milisegundos
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
List
<
byte
>
receivedBytes
=
new
List
<
byte
>();
byte
[]
bufferSalida
=
new
byte
[
1024
];
...
...
@@ -59,7 +61,19 @@ namespace gatewayGK.POSBC
while
(
true
)
{
int
bytesLeidos
=
0
;
try
{
bytesLeidos
=
socket
.
Receive
(
bufferSalida
,
0
,
bufferSalida
.
Length
,
SocketFlags
.
None
);
}
catch
(
SocketException
ex
)
{
if
(
ex
.
SocketErrorCode
==
SocketError
.
TimedOut
)
{
Log
.
Information
(
"Tiempo de espera agotado. No se recibieron más datos."
);
break
;
}
}
//Coloque 1 Porque POSBC si no tiene mas bytes que mandar, manda 1 y no 0
if
(
bytesLeidos
==
0
||
bytesLeidos
==
1
)
{
...
...
gatewayGK/POSBC/ReportStatusEventsRequestPosbcCmd.cs
View file @
7be3dce9
...
...
@@ -10,6 +10,7 @@ using System.Net.Sockets;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading
;
namespace
gatewayGK.POSBC
{
...
...
@@ -49,8 +50,10 @@ namespace gatewayGK.POSBC
// Enviar los datos
socket
.
Send
(
bufferRecibido
,
SocketFlags
.
None
);
Log
.
Information
(
$"Buffer de entrada enviado al servidor POSBC
{
bufferRecibido
}
"
);
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
// Configurar timeout para el socket (por ejemplo, 5 segundos)
socket
.
ReceiveTimeout
=
5000
;
// en milisegundos
// Buffer para recibir la respuesta - Revisar cual es la mejor manera de recibir ese
List
<
byte
>
receivedBytes
=
new
List
<
byte
>();
byte
[]
bufferSalida
=
new
byte
[
1024
];
...
...
@@ -58,7 +61,19 @@ namespace gatewayGK.POSBC
while
(
true
)
{
int
bytesLeidos
=
0
;
try
{
bytesLeidos
=
socket
.
Receive
(
bufferSalida
,
0
,
bufferSalida
.
Length
,
SocketFlags
.
None
);
}
catch
(
SocketException
ex
)
{
if
(
ex
.
SocketErrorCode
==
SocketError
.
TimedOut
)
{
Log
.
Information
(
"Tiempo de espera agotado. No se recibieron más datos."
);
break
;
}
}
//Coloque 1 Porque POSBC si no tiene mas bytes que mandar, manda 1 y no 0
if
(
bytesLeidos
==
0
||
bytesLeidos
==
1
)
{
...
...
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