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
ac503a47
Commit
ac503a47
authored
Jun 24, 2024
by
Jose Hugo Torres
Browse files
TCPListener logs
parent
b11f0788
Changes
3
Hide whitespace changes
Inline
Side-by-side
gatewayGK/Infraestructura/Util.cs
View file @
ac503a47
...
...
@@ -50,12 +50,15 @@ namespace GatewaySCO
/// </summary>
public
static
int
LongitudCodificada
(
byte
[]
bytesMensaje
)
{
if
(
bytesMensaje
.
Length
!=
4
)
{
throw
new
ArgumentException
(
"Longitud arreglo bytes con longitud codificada debe ser 4."
);
}
// Extrae longitud. Primeros 4 bytes del arreglo.
byte
[]
bytes
LongitudMensaje
=
new
byte
[
4
];
Buffer
.
BlockCopy
(
bytesMensaje
,
0
,
bytes
LongitudMensaje
,
0
,
4
);
byte
[]
bytes
=
new
byte
[
4
];
Buffer
.
BlockCopy
(
bytesMensaje
,
0
,
bytes
,
0
,
4
);
if
(
BitConverter
.
IsLittleEndian
)
Array
.
Reverse
(
bytes
LongitudMensaje
);
int
longitud
=
BitConverter
.
ToInt32
(
bytes
LongitudMensaje
,
0
);
Array
.
Reverse
(
bytes
);
int
longitud
=
BitConverter
.
ToInt32
(
bytes
,
0
);
return
longitud
;
}
...
...
gatewayGK/Program.cs
View file @
ac503a47
...
...
@@ -7,7 +7,7 @@ using EvaPosSrvAplicacionImp;
using
EvaPosSrvRespImp
;
using
gatewaySCO.POSBC
;
using
GatewayCHEC.Servidor
;
using
Servidor.TcpGateway
B
;
using
Servidor.TcpGateway
;
namespace
GatewaySCO
{
...
...
@@ -24,7 +24,7 @@ namespace GatewaySCO
ProgramGatewaySCO
program
=
new
();
program
.
LeeActivaConfiguracion
(
args
);
TcpGateway
B
gateway
=
new
TcpGateway
B
();
TcpGateway
gateway
=
new
TcpGateway
();
await
gateway
.
Start
();
}
...
...
gatewayGK/Servidor/TcpGateway
B
.cs
→
gatewayGK/Servidor/TcpGateway.cs
View file @
ac503a47
...
...
@@ -5,9 +5,9 @@ using System.Text;
using
GatewaySCO
;
using
Serilog
;
namespace
Servidor.TcpGateway
B
;
namespace
Servidor.TcpGateway
;
public
class
TcpGateway
B
public
class
TcpGateway
{
private
const
int
GatewayPort
=
6690
;
private
const
string
PosbcServer
=
"127.0.0.1"
;
...
...
@@ -86,8 +86,6 @@ public class TcpGatewayB
private
async
Task
ReceiveFromPosbcAndSendToChecAsync
(
NetworkStream
posbcStream
,
NetworkStream
checStream
)
{
byte
[]
buffer
=
new
byte
[
4096
];
while
(
true
)
{
try
...
...
@@ -98,9 +96,10 @@ public class TcpGatewayB
if
(
bytesRead
==
0
)
continue
;
// Si no se lee nada, continuar esperando
int
messageLength
=
Util
.
LongitudCodificada
(
lengthBuffer
);
Log
.
Debug
(
"
Mensajde de POSBC longitud {longitud}"
,
messageLength
);
Log
.
Debug
(
"
POSBC bytes cabecera leidos {bytes}, longitud en cabecera {longitud}"
,
bytesRead
,
messageLength
);
byte
[]
messageBuffer
=
new
byte
[
messageLength
];
bytesRead
=
await
posbcStream
.
ReadAsync
(
messageBuffer
,
0
,
messageLength
);
Log
.
Debug
(
"POSBC bytes cuerpo ledidos {bytes}"
,
bytesRead
);
if
(
bytesRead
==
0
)
continue
;
// Si no se lee nada, continuar esperando
// Remitir mensaje a CHEC
...
...
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