Skip to content

Commit

Permalink
fix: tmp remove origin printing
Browse files Browse the repository at this point in the history
  • Loading branch information
zzswang committed Feb 21, 2019
1 parent f9262c7 commit 231257b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ const logHandler = async (ctx, next) => {
logger.info(
{
session: ctx.session.id,
platform: ctx.session.username,
seq: ctx.no,
partial: !!ctx.state.partial,
cost: endAt - startedAt,
data: hexify(ctx.data),
origin: ctx.state.partial ? hexify(ctx.state.origin) : undefined,
// partial: !!ctx.state.partial,
// origin: ctx.state.partial ? hexify(ctx.state.origin) : undefined,
request: ctx.req,
response: hexify(ctx.res),
},
Expand All @@ -56,8 +57,9 @@ const logHandler = async (ctx, next) => {
logger.error(
{
session: ctx.session.id,
platform: ctx.session.username,
seq: ctx.no,
partial: !!ctx.state.partial,
// partial: !!ctx.state.partial,
error: {
type: err.constructor.name,
message: err.message,
Expand All @@ -77,7 +79,7 @@ const packetHandler = async (ctx, next) => {
const { session, state } = ctx;
const queue = (session.queue = session.queue || new BufferQueue());
queue.push(ctx.data);
state.partial = true;
// state.partial = true;

// 分包: 当前 header 长度不够
if (!queue.has(protocol.HEADER_LENGTH)) return;
Expand All @@ -94,9 +96,9 @@ const packetHandler = async (ctx, next) => {
if (!queue.has(length)) return;

// 进入包处理流程
state.origin = ctx.data;
// state.origin = ctx.data;
ctx.data = queue.shift(length);
state.partial = ctx.data !== state.origin; // 判断是否分包
// state.partial = ctx.data !== state.origin; // 判断是否分包

await next();

Expand Down

0 comments on commit 231257b

Please sign in to comment.