Well, after the good result of the last programming topic I had made, found here, we concluded that if you want to try making a InSim program in C++ you should try C# first. So with that inmind, I am going to attempt to teach myself with the help of sdether (Yea, your in this too buddy) how to make a pretty good program for LFS's InSim.
Here is where we start.
As you can see, I have played with the code abit, but there are things that I want to do, but don't quite understand. Such as, I want to make a function. This function would ask the user if they want to send a message to the server. If they reply with the Y key, then they are prompted to enter the message. The only problem is now, I don't have a clue how to make functions in C#, so this is where sdether comes in. (I bet he wishes he never helped me now.)
This is how you get a message you have typed to the LFS Server Via InSim.
Now if we wanted to do that over and over, and not to mention get the reply, how would we go about doing that?
Here is where we start.
using System;
using LiveForSpeed.InSim;
namespace ConsoleTester
{
class Program
{
static void Main( string[] args )
{
InSimHandler handler = new InSimHandler( false, false );
Configuration config = handler.Configuration;
Console.WriteLine( "Enter Your Server IP." );
config.LFSHost = Console.ReadLine( );
Console.WriteLine( "Enter Your Server Password." );
config.AdminPass = Console.ReadLine( );
Console.WriteLine( "Enter Your Server InSim Port." );
config.LFSHostPort = 30000;
config.ReplyPort = 30001;
config.UseKeepAlives = true;
config.UseSplitMessages = true;
config.GuaranteedDelivery = true;
handler.Initialize( );
Console.WriteLine( "LFS info :" );
Console.WriteLine( "Product : {0}", handler.Version.Product );
Console.WriteLine( "Version : {0}", handler.Version.Version );
Console.WriteLine( "Serial : {0}", handler.Version.Serial );
// Resets the cam.
// handler.SetCamera( handler.GetCameraPositionInfo( ) );
Console.WriteLine( "Press RETURN to exit" );
Console.ReadLine( );
handler.Close( );
}
}
}
As you can see, I have played with the code abit, but there are things that I want to do, but don't quite understand. Such as, I want to make a function. This function would ask the user if they want to send a message to the server. If they reply with the Y key, then they are prompted to enter the message. The only problem is now, I don't have a clue how to make functions in C#, so this is where sdether comes in. (I bet he wishes he never helped me now.)
This is how you get a message you have typed to the LFS Server Via InSim.
handler.SendMessage( Console.ReadLine( ) );
Now if we wanted to do that over and over, and not to mention get the reply, how would we go about doing that?