Uploaded 1.0.3 to the first post.
Changes
InSim Relay
Connecting to InSim relay is pretty simple and support needed no additions to the main InSim class. In this example we connect to relay, request the host list, then print out the name of each LFS host that is received.
Changes
- Fixed critical bug which was stopping the socket from correctly being released when the InSim connection closed. As a consequence InSim.Run() should now exit properly and InSim.IsConnected should now return the correct value in all situations.
- Added InSim Relay support. Check Example 7 in SparkExamples for a detailed example.
InSim Relay
Connecting to InSim relay is pretty simple and support needed no additions to the main InSim class. In this example we connect to relay, request the host list, then print out the name of each LFS host that is received.
using System;
using Spark;
using Spark.Packets;
using Spark.Helpers;
class Program
{
static void Main()
{
using (var insim = new InSim())
{
// Relay packets begin with IR_*.
insim.Bind<IR_HOS>(HostListReceived);
// Connect to the relay host.
insim.Connect("isrelay.lfs.net", 47474);
// Request for the host list to be sent.
insim.Send(new IR_HLR { ReqI = 255 });
insim.Run();
}
}
static void HostListReceived(IR_HOS hos)
{
// Loop through each host in the list.
foreach (var host in hos.Info)
{
// Print out the host name.
Console.WriteLine("Host: {0}", StringHelper.StripColors(host.HName));
// If this is the last host, print a blank line after it.
if (host.Flags.HasFlag(InfoFlags.HOS_LAST))
Console.WriteLine();
}
}
}