|
|
@ -8,7 +8,7 @@ using log4net;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BrakeMachine.Brack
|
|
|
|
namespace BrakeMachine.Brack
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class HttpHandler: SimpleChannelInboundHandler<DefaultHttpRequest>
|
|
|
|
public class HttpHandler : SimpleChannelInboundHandler<DefaultHttpRequest>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(HttpHandler));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(HttpHandler));
|
|
|
|
|
|
|
|
|
|
|
@ -29,17 +29,23 @@ namespace BrakeMachine.Brack
|
|
|
|
DefaultFullHttpResponse response = null;
|
|
|
|
DefaultFullHttpResponse response = null;
|
|
|
|
switch (req.Uri)
|
|
|
|
switch (req.Uri)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case "/Api/Manualsnap"://抓拍
|
|
|
|
case "/Api/Manualsnap": //抓拍
|
|
|
|
BrackMgr.Manualsnap();
|
|
|
|
BrackMgr.Manualsnap();
|
|
|
|
//this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(closeRfid.ToString())), TypePlain, closeRfid?OkLength: FailLength);
|
|
|
|
string msg = "抓拍成功";
|
|
|
|
|
|
|
|
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(msg)), TypePlain, OkLength);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "/Api/LicensePlateNumber": //车牌号码
|
|
|
|
|
|
|
|
if(!string.IsNullOrEmpty(BrackMgr.PlateNumber))
|
|
|
|
|
|
|
|
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(BrackMgr.PlateNumber)), TypePlain, OkLength);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(BrackMgr.PlateNumber)), TypePlain, FailLength);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
response = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus.NotFound, Unpooled.Empty, false);
|
|
|
|
response = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus.NotFound,
|
|
|
|
|
|
|
|
Unpooled.Empty, false);
|
|
|
|
ctx.WriteAndFlushAsync(response);
|
|
|
|
ctx.WriteAndFlushAsync(response);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WriteResponse(IChannelHandlerContext ctx, IByteBuffer buf, ICharSequence contentType,
|
|
|
|
void WriteResponse(IChannelHandlerContext ctx, IByteBuffer buf, ICharSequence contentType,
|
|
|
@ -58,7 +64,8 @@ namespace BrakeMachine.Brack
|
|
|
|
ctx.WriteAsync(response);
|
|
|
|
ctx.WriteAsync(response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) => context.CloseAsync();
|
|
|
|
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) =>
|
|
|
|
|
|
|
|
context.CloseAsync();
|
|
|
|
|
|
|
|
|
|
|
|
public override void ChannelReadComplete(IChannelHandlerContext context) => context.Flush();
|
|
|
|
public override void ChannelReadComplete(IChannelHandlerContext context) => context.Flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|