Prevent crashes when connection ID doesn't exist.

This commit is contained in:
GittyMac
2022-07-30 00:01:04 -04:00
parent 3507b97a54
commit f39a256b12

View File

@@ -7,17 +7,22 @@ using NetCoreServer;
public class A1_Sender {
public void SendToUser(TcpServer sendingServer, string guid, string message){
TcpSession session = sendingServer.FindSession(new Guid(guid));
try
{
TcpSession session = sendingServer.FindSession(new Guid(guid));
List<byte[]> d = new List<byte[]>();
Byte[] reply = Encoding.ASCII.GetBytes(message);
byte[] b2 = new byte[] {0x00};
d.Add(reply);
d.Add(b2);
byte[] b3 = d.SelectMany(a => a).ToArray();
List<byte[]> d = new List<byte[]>();
Byte[] reply = Encoding.ASCII.GetBytes(message);
byte[] b2 = new byte[] {0x00};
d.Add(reply);
d.Add(b2);
byte[] b3 = d.SelectMany(a => a).ToArray();
Console.WriteLine(message);
session?.Send(b3, 0, b3.Length);
Console.WriteLine(message);
session?.Send(b3, 0, b3.Length);
}catch(System.FormatException){
Console.WriteLine("[Error] Couldn't send to user...");
}
}
}