use of io.servicecomb.foundation.vertx.tcp.TcpOutputStream in project java-chassis by ServiceComb.
the class TestHighwayCodec method testEncodeRequest.
@Test
public void testEncodeRequest() {
boolean status = true;
try {
commonMock();
TcpOutputStream os = HighwayCodec.encodeRequest(invocation, operationProtobuf);
Assert.assertNotNull(os);
Assert.assertArrayEquals(TcpParser.TCP_MAGIC, os.getBuffer().getBytes(0, 7));
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
use of io.servicecomb.foundation.vertx.tcp.TcpOutputStream in project java-chassis by ServiceComb.
the class TcpClient method tryLogin.
protected synchronized void tryLogin() {
if (!remoteSupportLogin) {
LOGGER.error("remote not support login, address={}.", socketAddress.toString());
onLoginSuccess();
return;
}
if (clientConfig.getTcpLogin() == null) {
LOGGER.error("local not support login, address={}.", socketAddress.toString());
onLoginSuccess();
return;
}
this.status = Status.TRY_LOGIN;
LOGGER.info("try login to address {}", socketAddress.toString());
try (TcpOutputStream os = clientConfig.getTcpLogin().createLogin()) {
requestMap.put(os.getMsgId(), new TcpRequest(clientConfig.getRequestTimeoutMillis(), this::onLoginResponse));
netSocket.write(os.getBuffer());
}
}
use of io.servicecomb.foundation.vertx.tcp.TcpOutputStream in project java-chassis by ServiceComb.
the class TestTcp method testTcpOutputStream.
@Test
public void testTcpOutputStream() {
TcpOutputStream oStream = new TcpOutputStream();
oStream.close();
Buffer buffer = oStream.getBuffer();
Assert.assertArrayEquals(TcpParser.TCP_MAGIC, buffer.getBytes(0, TcpParser.TCP_MAGIC.length));
Assert.assertEquals(oStream.getMsgId(), buffer.getLong(TcpParser.TCP_MAGIC.length));
}
Aggregations