Skip to content

Commit

Permalink
updated samples and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed Apr 15, 2024
1 parent 24dcc13 commit 6e33402
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion samples/CommandServer/ADD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async ValueTask ExecuteAsync(IAppSession session, StringPackageInfo packa
.Select(p => int.Parse(p))
.Sum();

await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"), cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion samples/CommandServer/MULT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async ValueTask ExecuteAsync(IAppSession session, StringPackageInfo packa
.Select(p => int.Parse(p))
.Aggregate((x, y) => x * y);

await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"), cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion samples/CommandServer/SUB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async ValueTask ExecuteAsync(IAppSession session, StringPackageInfo packa
.Select(p => int.Parse(p))
.Aggregate((x, y) => x - y);

await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"), cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion test/SuperSocket.Tests.Command/MIN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async ValueTask ExecuteAsync(IAppSession session, StringPackageInfo packa
var result = package.Parameters
.Select(p => int.Parse(p)).OrderBy(x => x).FirstOrDefault();

await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes(result.ToString() + "\r\n"), cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion test/SuperSocket.Tests.Command/SORT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async ValueTask ExecuteAsync(IAppSession session, StringPackageInfo packa
var result = string.Join(' ', package.Parameters
.Select(p => int.Parse(p)).OrderBy(x => x).Select(x => x.ToString()));

await session.SendAsync(Encoding.UTF8.GetBytes($"{nameof(SORT)} {result}\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes($"{nameof(SORT)} {result}\r\n"), cancellationToken);
}
}
}
6 changes: 3 additions & 3 deletions test/SuperSocket.Tests/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async ValueTask ExecuteAsync(MySession session, StringPackageInfo package

var socketSession = session as IAppSession;
// encode the text message by encoder
await socketSession.SendAsync(_encoder, result.ToString() + "\r\n");
await socketSession.SendAsync(_encoder, result.ToString() + "\r\n", cancellationToken);
}
}

Expand All @@ -96,7 +96,7 @@ public class POW : JsonAsyncCommand<IAppSession, PowData>
{
protected override async ValueTask ExecuteJsonAsync(IAppSession session, PowData data, CancellationToken cancellationToken)
{
await session.SendAsync(Encoding.UTF8.GetBytes($"{Math.Pow(data.X, data.Y)}\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes($"{Math.Pow(data.X, data.Y)}\r\n"), cancellationToken);
}
}

Expand All @@ -110,7 +110,7 @@ public class MAX : JsonAsyncCommand<IAppSession, MaxData>
protected override async ValueTask ExecuteJsonAsync(IAppSession session, MaxData data, CancellationToken cancellationToken)
{
var maxValue = data.Numbers.OrderByDescending(i => i).FirstOrDefault();
await session.SendAsync(Encoding.UTF8.GetBytes($"{maxValue}\r\n"));
await session.SendAsync(Encoding.UTF8.GetBytes($"{maxValue}\r\n"), cancellationToken);
}
}
}

0 comments on commit 6e33402

Please sign in to comment.