Skip to content

Commit 3c8d32e

Browse files
authored
Merge branch 'dev' into dependabot/npm_and_yarn/docs/npm_and_yarn-dec7325368
2 parents 07bd7f4 + b95ff13 commit 3c8d32e

File tree

13 files changed

+75
-43
lines changed

13 files changed

+75
-43
lines changed

FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
buy_me_a_coffee: alec1o

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,19 @@ powered by <a href="https://github.com/alec1o">ALEC1O</a><sub/>
5959
<td>
6060
<br>
6161
<div>
62-
<a href="https://www.kezero.com/?invite_user='Netly'"><img alt="KeZero sponsor notice" src="/static/KeZero%20sponsor.png" height="35px" /></a>
63-
<br>
64-
<a href="https://www.jetbrains.com/community/opensource/"><img alt="JetBrains sponsor notice" src="/static/JetBrains%20sponsor.png" height="35px" /></a>
62+
<a href="https://www.buymeacoffee.com/alec1o">
63+
<img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=☕&slug=alec1o&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" />&nbsp;&nbsp;
64+
<sup>Keep Netly alive – sponsor it on Buy Me a Coffee.</sup>
65+
</a>
66+
<br><hr>
67+
<a href="https://www.kezero.com/?invite=netly" justify="start" align="start">
68+
<img src="https://raw.githubusercontent.com/kezerocom/BrandAsset/refs/heads/main/logo/v2/blue.png" alt="KeZero logo." height="45px">&nbsp;&nbsp;
69+
<sup>KeZero sponsor Netly with hosting infrastructure and website domain.</sup>
70+
</a><hr>
71+
<a href="https://www.jetbrains.com/community/opensource/">
72+
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo." height="30px">&nbsp;&nbsp;
73+
<sup>Netly receives JetBrains' IDE for free, Thanks to their generous sponsorship.</sup>
74+
</a><br>
6575
</div>
6676
<br>
6777
</td>
@@ -169,7 +179,12 @@ powered by <a href="https://github.com/alec1o">ALEC1O</a><sub/>
169179
- <sub>[.NET](https://dotnet.microsoft.com) (SDK)</sub>
170180
- <sub>[Mono](https://mono-project.com) (SDK)</sub>
171181
- <sub>[Unity](https://unity.com) (Engine)</sub>
172-
- <sub>[Operating system](https://en.wikipedia.org/wiki/Operating_system) (OS)</sub> - <sub>Linux</sub> - <sub>Windows</sub> - <sub>Android</sub> - <sub>iOS</sub> - <sub>macOS</sub><br><br>
182+
- <sub>[Operating system](https://en.wikipedia.org/wiki/Operating_system) (OS)</sub>
183+
- <sub>Android</sub>
184+
- <sub>iOS</sub>
185+
- <sub>Windows</sub>
186+
- <sub>Linux</sub>
187+
- <sub>macOS</sub><br><br>
173188
<sub><strong>Notice</strong>: <i>This library might run on all devices. If it doesn't work on any device, it
174189
should be considered a bug and reported.<i><sub>
175190

src/http/partials/Server/HTTP.ServerTo.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public Task Open(Uri host)
7070
}
7171
catch (Exception e)
7272
{
73+
NetlyEnvironment.Logger.Create(e);
7374
_server.MyServerOn.OnError?.Invoke(null, e);
7475
}
7576
finally
@@ -101,9 +102,9 @@ public Task Close()
101102
foreach (var socket in _websocketList) socket.To.Close();
102103
}
103104
}
104-
catch
105+
catch (Exception e)
105106
{
106-
// Ignored
107+
NetlyEnvironment.Logger.Create(e);
107108
}
108109
finally
109110
{
@@ -170,14 +171,21 @@ private void InitAccept()
170171

171172
void AcceptCallback(IAsyncResult result)
172173
{
173-
if (IsOpened)
174+
try
174175
{
175-
HandleContext(_listener.EndGetContext(result));
176-
InitAccept();
176+
if (IsOpened)
177+
{
178+
HandleContext(_listener.EndGetContext(result));
179+
InitAccept();
180+
}
181+
else
182+
{
183+
Close();
184+
}
177185
}
178-
else
186+
catch (Exception e)
179187
{
180-
Close();
188+
NetlyEnvironment.Logger.Create(e);
181189
}
182190
}
183191

@@ -196,15 +204,14 @@ void HandleContext(HttpListenerContext context)
196204
}
197205
catch (Exception e)
198206
{
207+
NetlyEnvironment.Logger.Create($"{this}: {e}");
199208
if (socket?.WebSocket != null)
200209
await socket.WebSocket.CloseAsync
201210
(
202211
WebSocketCloseStatus.InternalServerError,
203212
string.Empty,
204213
CancellationToken.None
205214
);
206-
207-
NetlyEnvironment.Logger.Create($"{this}: {e}");
208215
}
209216
});
210217
}
@@ -276,8 +283,9 @@ private void HandleConnection(HttpListenerContext context, HttpListenerWebSocket
276283
{
277284
descriptor.Next = descriptors[i + 1];
278285
}
279-
catch
286+
catch (Exception e)
280287
{
288+
NetlyEnvironment.Logger.Create(e);
281289
descriptor.Next = null;
282290
}
283291
}

src/http/partials/Websocket/HTTP.WebSocketTo.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Task Open(Uri host)
8080
Thread.Sleep(TimeSpan.FromMilliseconds(byte.MaxValue)); // (Only client side)
8181
ws = new ClientWebSocket();
8282
}
83-
83+
8484
foreach (var header in Headers) ws.Options.SetRequestHeader(header.Key, header.Value);
8585

8686
_socket._on.OnModify?.Invoke(null, ws);
@@ -99,14 +99,16 @@ public Task Open(Uri host)
9999
}
100100
catch (Exception e)
101101
{
102+
NetlyEnvironment.Logger.Create(e);
103+
102104
try
103105
{
104106
await _websocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, string.Empty,
105107
CancellationToken.None);
106108
}
107-
catch
109+
catch(Exception e2)
108110
{
109-
// ignored
111+
NetlyEnvironment.Logger.Create(e2);
110112
}
111113
finally
112114
{
@@ -176,7 +178,7 @@ public Task Close(WebSocketCloseStatus status)
176178
catch (Exception e)
177179
{
178180
// HACK: FIX IT
179-
Console.WriteLine(e);
181+
NetlyEnvironment.Logger.Create(e);
180182
}
181183
finally
182184
{
@@ -298,8 +300,9 @@ private async void ReceiveJob(object _)
298300
_socket._on.OnData?.Invoke(null, (data, messageType));
299301
}
300302
}
301-
catch
303+
catch(Exception e)
302304
{
305+
NetlyEnvironment.Logger.Create(e);
303306
closeStatus = WebSocketCloseStatus.EndpointUnavailable;
304307
}
305308
finally

src/rudp/partials/RUDP.ClientTo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public Task Open(Host host)
8383
}
8484
catch (Exception e)
8585
{
86+
// logger
87+
NetlyEnvironment.Logger.Create(e);
8688
// error on open connection
8789
On.OnError?.Invoke(null, e);
8890
_connection = null;
89-
// logger
90-
NetlyEnvironment.Logger.Create(e);
9191
}
9292
finally
9393
{

src/rudp/partials/RUDP.ServerTo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public Task Open(Host host)
6969
}
7070
catch (Exception e)
7171
{
72+
NetlyEnvironment.Logger.Create(e);
7273
_isClosed = true;
7374
On.OnError?.Invoke(null, e);
7475
}
@@ -373,7 +374,7 @@ private void ContentUpdate()
373374

374375
// invoke new client
375376
On.OnAccept?.Invoke(null, client);
376-
377+
377378
// start client connection callback
378379
client._on?.OnModify(null, _socket);
379380
client._on?.OnOpen(null, null);

src/tcp/partials/TCP.ClientTo.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public Task Open(Host host)
119119
}
120120
catch (Exception e)
121121
{
122+
NetlyEnvironment.Logger.Create(e);
122123
On.OnError?.Invoke(null, e);
123124
}
124125
finally
@@ -221,7 +222,7 @@ public void Event(string name, string data)
221222

222223
public void Event(string name, string data, Encoding encoding)
223224
{
224-
if (CanSend == false || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(data))return;
225+
if (CanSend == false || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(data)) return;
225226

226227
SendDispatch(NetlyEnvironment.EventManager.Create(name, data.GetBytes(encoding)));
227228
}
@@ -242,8 +243,9 @@ void Callback()
242243
InitEncryption();
243244
_serverValidatorCallback?.Invoke(_client, true);
244245
}
245-
catch
246+
catch (Exception e)
246247
{
248+
NetlyEnvironment.Logger.Create(e);
247249
_serverValidatorCallback?.Invoke(_client, false);
248250
}
249251
}
@@ -386,9 +388,9 @@ private void SendDispatch(byte[] bytes)
386388
else
387389
_netStream?.BeginWrite(bytes, 0, bytes.Length, null, null);
388390
}
389-
catch
391+
catch(Exception e)
390392
{
391-
// Ignored
393+
NetlyEnvironment.Logger.Create(e);
392394
}
393395
}
394396

src/tcp/partials/TCP.ServerTo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public Task Open(Host host, int backlog)
103103
}
104104
catch (Exception e)
105105
{
106+
NetlyEnvironment.Logger.Create(e);
106107
On.OnError?.Invoke(null, e);
107108
}
108109

@@ -126,9 +127,9 @@ public Task Close()
126127

127128
_socket.Dispose();
128129
}
129-
catch
130+
catch (Exception e)
130131
{
131-
// Ignored
132+
NetlyEnvironment.Logger.Create(e);
132133
}
133134
finally
134135
{

src/udp/partials/UDP.ClientTo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public Task Open(Host host)
7272
}
7373
catch (Exception e)
7474
{
75-
_isClosed = true;
7675
NetlyEnvironment.Logger.Create(e);
76+
_isClosed = true;
7777
On.OnError?.Invoke(null, e);
7878
}
7979
finally

src/udp/partials/UDP.ServerTo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public Task Open(Host host)
6868
}
6969
catch (Exception e)
7070
{
71+
NetlyEnvironment.Logger.Create(e);
7172
_isClosed = true;
7273
On.OnError?.Invoke(null, e);
7374
}
@@ -110,9 +111,9 @@ public Task Close()
110111
_socket?.Close();
111112
_socket?.Dispose();
112113
}
113-
catch
114+
catch (Exception e)
114115
{
115-
// Ignored
116+
NetlyEnvironment.Logger.Create(e);
116117
}
117118
finally
118119
{

0 commit comments

Comments
 (0)