Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
432a1b1e
Commit
432a1b1e
authored
Apr 09, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Netty 服务端 结果写入客户端方式修改为回调方式
parent
08c1cab7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
NettyPluginServerHandler.java
...m/byit/server/netty/handler/NettyPluginServerHandler.java
+19
-2
No files found.
byit-plugin-core/myth-plugin-rpc-server/src/main/java/com/byit/server/netty/handler/NettyPluginServerHandler.java
View file @
432a1b1e
...
@@ -2,10 +2,12 @@ package com.byit.server.netty.handler;
...
@@ -2,10 +2,12 @@ package com.byit.server.netty.handler;
import
com.byit.dto.web.ReturnResult
;
import
com.byit.dto.web.ReturnResult
;
import
com.byit.enums.ResponseTyEnum
;
import
com.byit.enums.ResponseTyEnum
;
import
com.byit.executor.handler.interfaces.IJobHandler
;
import
com.byit.factory.PluginServerFactory
;
import
com.byit.factory.PluginServerFactory
;
import
com.byit.packet.request.PluginRpcRequestPacket
;
import
com.byit.packet.request.PluginRpcRequestPacket
;
import
com.byit.packet.response.PluginRpcResponsePacket
;
import
com.byit.packet.response.PluginRpcResponsePacket
;
import
com.byit.param.ResultCallback
;
import
com.byit.task.handler.interfaces.IJobHandler
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.SimpleChannelInboundHandler
;
import
io.netty.channel.SimpleChannelInboundHandler
;
...
@@ -26,6 +28,12 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
...
@@ -26,6 +28,12 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
this
.
threadPoolExecutor
=
threadPoolExecutor
;
this
.
threadPoolExecutor
=
threadPoolExecutor
;
}
}
/**
* //TODO 这一块有问题 不能返回两次结果 考虑能否加一个结果回调,回调的方式由自己实现
* @param ctx
* @param msg
* @throws Exception
*/
@Override
@Override
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
throws
Exception
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
PluginRpcRequestPacket
msg
)
throws
Exception
{
PluginRpcResponsePacket
transferPluginRpcResponse
=
new
PluginRpcResponsePacket
();
PluginRpcResponsePacket
transferPluginRpcResponse
=
new
PluginRpcResponsePacket
();
...
@@ -49,9 +57,18 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
...
@@ -49,9 +57,18 @@ public class NettyPluginServerHandler extends SimpleChannelInboundHandler<Plugin
rpcResponsePacket
.
setExtension
(
msg
.
getExtension
());
rpcResponsePacket
.
setExtension
(
msg
.
getExtension
());
}
}
rpcResponsePacket
.
setType
(
ResponseTyEnum
.
RESPONSE
.
getType
());
rpcResponsePacket
.
setType
(
ResponseTyEnum
.
RESPONSE
.
getType
());
ctx
.
channel
().
writeAndFlush
(
rpcResponsePacket
);
rpcResponsePacket
.
setRequestId
(
msg
.
getRequestId
());
//ctx.channel().writeAndFlush(rpcResponsePacket);
ResultCallback
resultCallback
=
msg
.
getResultCallback
();
if
(
resultCallback
!=
null
)
{
System
.
out
.
println
(
resultCallback
);
resultCallback
.
resultCallback
(
ctx
,
rpcResponsePacket
);
}
});
});
transferPluginRpcResponse
.
setRequestId
(
msg
.
getRequestId
());
transferPluginRpcResponse
.
setStatus
(
true
);
transferPluginRpcResponse
.
setStatus
(
true
);
transferPluginRpcResponse
.
setCode
(
"00000000"
);
transferPluginRpcResponse
.
setMsg
(
"调用成功"
);
transferPluginRpcResponse
.
setMsg
(
"调用成功"
);
transferPluginRpcResponse
.
setExtension
(
msg
.
getExtension
());
transferPluginRpcResponse
.
setExtension
(
msg
.
getExtension
());
transferPluginRpcResponse
.
setType
(
ResponseTyEnum
.
TRANSFER
.
getType
());
transferPluginRpcResponse
.
setType
(
ResponseTyEnum
.
TRANSFER
.
getType
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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