sync code
This commit is contained in:
1 parent
082c25b252
commit
4467c929ce
3 files changed
+52
-8
No files matched your search
@@ -9,4 +9,10 @@
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -48,4 +48,9 @@ internal class BotExtPipe
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_pipeServerStream.Close();
|
||||
}
|
||||
|
||||
}
|
||||
+41
-8
@@ -1,28 +1,61 @@
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace BotBridge;
|
||||
|
||||
|
||||
internal class Program
|
||||
{
|
||||
[RequiresDynamicCode("Calls Microsoft.Extensions.Logging.LoggerFactory.Create(Action<ILoggingBuilder>)")]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
BotExtHost botExtHost = new BotExtHost();
|
||||
|
||||
while (true)
|
||||
{
|
||||
BotExtPipe botExtPipe = new BotExtPipe("BotExtPipe");
|
||||
botExtPipe.WaitForConnection();
|
||||
using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder.AddSimpleConsole(options =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.SingleLine = true;
|
||||
options.TimestampFormat = "HH:mm:ss ";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
ILogger<Program> logger = loggerFactory.CreateLogger<Program>();
|
||||
using (logger.BeginScope("[scope is enabled]"))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//BotExtPipe botExtPipe = new BotExtPipe("BotExtPipe");
|
||||
//botExtPipe.WaitForConnection();
|
||||
|
||||
//byte[] clientData = botExtPipe.ReadData();
|
||||
//logger.LogInformation("Recived: " + Encoding.UTF8.GetString(clientData));
|
||||
//botExtPipe.WriteData(Encoding.UTF8.GetBytes("Hello from BotExtHost"));
|
||||
//logger.LogInformation("Send: Hello from BotExtHost");
|
||||
//botExtPipe.Close();
|
||||
|
||||
//while (true)
|
||||
//{
|
||||
|
||||
// byte[] clientData = botExtPipe.ReadData();
|
||||
// //Console.WriteLine(Encoding.UTF8.GetString(clientData));
|
||||
// botExtPipe.Close();
|
||||
// //botExtHost.WriteData(clientData);
|
||||
// //byte[] serverData = botExtHost.ReadData();
|
||||
// //botExtPipe.WriteData(serverData);
|
||||
|
||||
//}
|
||||
|
||||
byte[] clientData = botExtPipe.ReadData();
|
||||
botExtHost.WriteData(clientData);
|
||||
byte[] serverData = botExtHost.ReadData();
|
||||
botExtPipe.WriteData(serverData);
|
||||
|
||||
logger.LogInformation("Recived from chrom:" + Encoding.UTF8.GetString(serverData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user