Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IPCServer.cs
Go to the documentation of this file.
1using System;
2using System.IO;
5
7
8public class IPCServer : IPCBase
9{
10 private string _serverName;
11
13
14 public event Action OnClientAccess;
15
16 public override event Action<byte[]> OnDataArrive
17 {
18 add
19 {
21 }
22 remove
23 {
25 }
26 }
27
32
33 public void Init(string serverName)
34 {
35 _serverName = serverName;
36 }
37
38 private void LazyCreatePipe()
39 {
40 if (GetPipeStream() == null)
41 {
44 }
45 }
46
47 public override void ReadCallback(IAsyncResult result)
48 {
50 base.ReadCallback(result);
51 if (!obj.CancelToken.IsCancellationRequested)
52 {
54 }
55 else
56 {
57 WeGameHelper.WriteDebugString("servcer.ReadCallback cancel");
58 }
59 }
60
67
68 private void RestartListen()
69 {
71 }
72
73 private void ConnectionCallback(IAsyncResult result)
74 {
75 try
76 {
78 WeGameHelper.WriteDebugString("Connected in");
80 if (!((CancellationToken)result.AsyncState).IsCancellationRequested)
81 {
83 }
84 else
85 {
86 WeGameHelper.WriteDebugString("ConnectionCallback but user cancel");
87 }
88 }
89 catch (IOException ex)
90 {
91 _pipeBrokenFlag = true;
92 WeGameHelper.WriteDebugString("ConnectionCallback Exception, {0}", ex.Message);
93 }
94 }
95
96 public void ContinueReadOrWait()
97 {
98 if (GetPipeStream().IsConnected)
99 {
101 return;
102 }
103 try
104 {
106 }
107 catch (IOException ex)
108 {
109 _pipeBrokenFlag = true;
110 WeGameHelper.WriteDebugString("ContinueReadOrWait Exception, {0}", ex.Message);
111 }
112 }
113
115 {
117 {
118 if (this.OnClientAccess != null)
119 {
120 this.OnClientAccess();
121 }
122 _haveClientAccessFlag = false;
123 }
124 }
125
132
134 {
135 if (_pipeBrokenFlag)
136 {
137 Reset();
138 _pipeBrokenFlag = false;
140 }
141 }
142
143 public void Tick()
144 {
146 }
147}
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
virtual string Message
Definition Exception.cs:100
void EndWaitForConnection(IAsyncResult asyncResult)
IAsyncResult BeginWaitForConnection(AsyncCallback? callback, object? state)
CancellationTokenSource _cancelTokenSrc
Definition IPCBase.cs:27
virtual bool BeginReadData()
Definition IPCBase.cs:103
virtual void ProcessDataArriveEvent()
Definition IPCBase.cs:86
Action< byte[]> _onDataArrive
Definition IPCBase.cs:29
volatile bool _pipeBrokenFlag
Definition IPCBase.cs:23
void ConnectionCallback(IAsyncResult result)
Definition IPCServer.cs:73
NamedPipeServerStream GetPipeStream()
Definition IPCServer.cs:28
override Action< byte[]> OnDataArrive
Definition IPCServer.cs:17
override void ReadCallback(IAsyncResult result)
Definition IPCServer.cs:47
void Init(string serverName)
Definition IPCServer.cs:33
static void WriteDebugString(string format, params object[] args)