diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/Helpers/PipeServer.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Gestor.Application/Helpers/PipeServer.cs')
| -rw-r--r-- | Gestor.Application/Helpers/PipeServer.cs | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/Gestor.Application/Helpers/PipeServer.cs b/Gestor.Application/Helpers/PipeServer.cs deleted file mode 100644 index fa42e03..0000000 --- a/Gestor.Application/Helpers/PipeServer.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Assinador.Model.Common;
-using Gestor.Application.Actions;
-using Newtonsoft.Json;
-using System;
-using System.IO;
-using System.IO.Pipes;
-using System.Runtime.CompilerServices;
-using System.Security.AccessControl;
-using System.Security.Principal;
-
-namespace Gestor.Application.Helpers
-{
- public class PipeServer : IDisposable
- {
- private string _pipeName;
-
- private NamedPipeServerStream Pipe
- {
- get;
- set;
- }
-
- public PipeServer()
- {
- }
-
- private bool Create()
- {
- bool flag;
- bool flag1 = true;
- try
- {
- (new NamedPipeClientStream(".", this._pipeName, PipeDirection.Out, PipeOptions.Asynchronous)).Connect(1000);
- }
- catch (TimeoutException timeoutException)
- {
- flag1 = false;
- }
- catch (Exception exception)
- {
- flag = false;
- return flag;
- }
- if (flag1)
- {
- return true;
- }
- try
- {
- PipeSecurity pipeSecurity = new PipeSecurity();
- SecurityIdentifier securityIdentifier = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
- securityIdentifier.Translate(typeof(NTAccount));
- pipeSecurity.SetAccessRule(new PipeAccessRule(securityIdentifier, PipeAccessRights.ReadWrite, AccessControlType.Allow));
- this.Pipe = new NamedPipeServerStream(this._pipeName, PipeDirection.In, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 1, 1, pipeSecurity);
- this.Pipe.BeginWaitForConnection(new AsyncCallback(this.WaitForConnectionCallBack), this.Pipe);
- return true;
- }
- catch (Exception exception1)
- {
- flag = false;
- }
- return flag;
- }
-
- public bool CreateServer(string name)
- {
- this._pipeName = name;
- return this.Create();
- }
-
- public void Dispose()
- {
- this.Pipe.Dispose();
- }
-
- private void Handle(string message)
- {
- if (message == null)
- {
- return;
- }
- PipeMessageResult pipeMessageResult = JsonConvert.DeserializeObject<PipeMessageResult>(message);
- Action<PipeMessageResult> acessarHoster = Gestor.Application.Actions.Actions.AcessarHoster;
- if (acessarHoster == null)
- {
- return;
- }
- acessarHoster(pipeMessageResult);
- }
-
- private void WaitForConnectionCallBack(IAsyncResult iar)
- {
- try
- {
- NamedPipeServerStream asyncState = (NamedPipeServerStream)iar.AsyncState;
- asyncState.EndWaitForConnection(iar);
- using (StreamReader streamReader = new StreamReader(this.Pipe))
- {
- string str = streamReader.ReadLine();
- if ((str == null ? false : str.IndexOf("exit", StringComparison.InvariantCultureIgnoreCase) > -1))
- {
- this.Dispose();
- }
- this.Handle(str);
- }
- asyncState.Close();
- asyncState = null;
- this.Create();
- }
- catch
- {
- }
- }
- }
-}
\ No newline at end of file |