use of org.eclipse.milo.opcua.stack.core.channel.messages.MessageType in project milo by eclipse.
the class UascServerAsymmetricHandler method decode.
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
if (buffer.readableBytes() >= HEADER_LENGTH) {
int messageLength = getMessageLength(buffer, maxChunkSize);
if (buffer.readableBytes() >= messageLength) {
MessageType messageType = MessageType.fromMediumInt(buffer.getMediumLE(buffer.readerIndex()));
switch(messageType) {
case OpenSecureChannel:
onOpenSecureChannel(ctx, buffer.readSlice(messageLength));
break;
case CloseSecureChannel:
logger.debug("Received CloseSecureChannelRequest");
buffer.skipBytes(messageLength);
if (secureChannelTimeout != null) {
secureChannelTimeout.cancel();
secureChannelTimeout = null;
}
ctx.close();
break;
default:
throw new UaException(StatusCodes.Bad_TcpMessageTypeInvalid, "unexpected MessageType: " + messageType);
}
}
}
}
Aggregations