This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Subversionary/IPCPatches
Replace marserializer with IPC
- Loading branch information
Showing
15 changed files
with
176 additions
and
225 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.IO.Pipes; | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.IPC; | ||
|
||
public class Client | ||
{ | ||
public string ConnRecv(string name) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "IPC-Client", $"Trying to open client with pipe name {name}"); | ||
using NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", name, PipeDirection.In); | ||
|
||
try | ||
{ | ||
pipeClient.Connect(150); // Pipe should connect immediately | ||
} | ||
catch(TimeoutException) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "IPC-Client", $"Connection timed out on pipe {name}, pipe not being created?"); | ||
return ""; | ||
} | ||
|
||
using StreamReader reader = new StreamReader(pipeClient); | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
using System.IO.Pipes; | ||
using System.Text; | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.IPC; | ||
|
||
public class Server | ||
{ | ||
public async Task ReadySend(string name, string data) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.INFO, "IPC-SERVER", $"Opening {name}"); | ||
await using NamedPipeServerStream pipeServer = new NamedPipeServerStream(name, PipeDirection.Out); | ||
await pipeServer.WaitForConnectionAsync(); | ||
|
||
byte[] buffer = Encoding.UTF8.GetBytes(data); | ||
await pipeServer.WriteAsync(buffer); | ||
|
||
MarseyLogger.Log(MarseyLogger.LogType.INFO, "IPC-SERVER", $"Closing {name}"); | ||
pipeServer.Close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.