so im using lib from https://github.com/alexmcbride/insimdotnet i followed his exact code from his github wiki but i go no results.
when i run this i get no host list or it doesnt even connect to any host i tired every way possible i know
please correct me if im wrong..
when i run this i get no host list or it doesnt even connect to any host i tired every way possible i know
please correct me if im wrong..
using System;
using System.IO;
using InSimDotNet;
using InSimDotNet.Packets;
using InSimDotNet.Helpers;
namespace LFSInSimRelay
{
class Program
{
// File to log messages to
private static readonly string LogFile = "mso_log.txt";
static void Main(string[] args)
{
Console.WriteLine("Starting LFS InSim Relay...");
InSim insim = new InSim();
// Bind event handlers
insim.Bind<IS_NCN>(NewConnection);
insim.Bind<IS_MSO>(MessageOut); // Add MSO event handler
// Initialize InSim relay
insim.Initialize(new InSimSettings {
IsRelayHost = true
});
Console.WriteLine("InSim relay initialized.");
Console.WriteLine("Selecting host:");
// Select a host
insim.Send(new IR_SEL {
HName = "", // Host to select
Admin = "", // Optional admin pass
Spec = String.Empty // Optional spectator pass
});
Console.WriteLine("Requesting current connection list...");
// Request connection list
insim.Send(new IS_TINY {
ReqI = 1,
SubT = TinyType.TINY_NCN,
});
Console.WriteLine("Monitoring for new connections and MSO messages.");
Console.WriteLine("Press Enter to exit.");
Console.ReadLine();
// Clean up
insim.Disconnect();
}
static void NewConnection(InSim insim, IS_NCN ncn)
{
// Output name of each player connected to the host
Console.WriteLine("Player connected: {0}", StringHelper.StripColors(ncn.PName));
}
static void MessageOut(InSim insim, IS_MSO mso)
{
// Strip color codes from message
string cleanMessage = StringHelper.StripColors(mso.Msg);
// Format the message with user info when available
string logMessage;
if (mso.UCID > 0)
{
// Message from a user
logMessage = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [USER:{mso.UCID}] {cleanMessage}";
}
else
{
// System message
logMessage = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [SYSTEM] {cleanMessage}";
}
// Output to console
Console.WriteLine(logMessage);
// Log to file
try
{
File.AppendAllText(LogFile, logMessage + Environment.NewLine);
}
catch (Exception ex)
{
Console.WriteLine($"Error writing to log file: {ex.Message}");
}
}
}
}