The online racing simulator
LFSLib.NET 0.14b
(11 posts, started )
LFSLib.NET 0.14b
Some bug fixes related to TCP handling that deal with connections dying, plus some cosmetic clean-up. Thanks to Hollywood for feedback on the TCP bugs and naming convention clean-up.

Details are here

Docs, binaries, etc. are here
Nice

[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] FullMotion.LiveForSpeed.InSim.Enums[/SIZE]
[SIZE=2][COLOR=#0000ff]Module[/COLOR][/SIZE][SIZE=2] Module1[/SIZE]

[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]WithEvents[/COLOR][/SIZE][SIZE=2] InSimHandler [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] InSim.InSimHandler[/SIZE]

[SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Main()[/SIZE]
[SIZE=2]ConnectToLFS([/SIZE][SIZE=2][COLOR=#a31515]"127.0.0.1"[/COLOR][/SIZE][SIZE=2], 29999)[/SIZE]
[SIZE=2]Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Press Enter to Exit"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]Console.ReadLine()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ConnectToLFS([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] IP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Port [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2]InSimHandler.Configuration.LFSHost = IP[/SIZE]
[SIZE=2]InSimHandler.Configuration.LFSHostPort = Port[/SIZE]
[SIZE=2]InSimHandler.Configuration.UseTCP = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2]InSimHandler.Configuration.ReplyPort = 30000[/SIZE]
[SIZE=2]InSimHandler.Configuration.Local = [/SIZE][SIZE=2][COLOR=#0000ff]True [/COLOR][/SIZE]
[SIZE=2]InSimHandler.Configuration.ProgramName = [/SIZE][SIZE=2][COLOR=#a31515]"InGame"[/COLOR][/SIZE]
[SIZE=2]Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Try to connect"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]InSimHandler.Initialize(3)[/SIZE]
[SIZE=2]Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Connected"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]InSimHandler.RequestState()[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]InSimHandler = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Failed to connect "[/COLOR][/SIZE][SIZE=2] & vbCrLf & ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] InSimHandler_Updated([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] InS [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] FullMotion.LiveForSpeed.InSim.Events.State) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] InSimHandler.[B][COLOR=red]LFSState[/COLOR][/B][/SIZE]
[SIZE=2]Console.WriteLine(InS.Weather)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Module[/COLOR][/SIZE]

I know you are not very familiar with vb Syntax.
But do you know why i get an error at the Handles InSimHandler.LFSState ?
With the old LFSLib it worked.

I get the error

"Fehler 1 Die Methode "Private Sub InSimHandler_Updated(InS As FullMotion.LiveForSpeed.InSim.Events.State)" kann das Ereignis "Public Event LFSState(sender As FullMotion.LiveForSpeed.InSim.InSimHandler, e As FullMotion.LiveForSpeed.InSim.Events.State)" nicht behandeln, da sie nicht die gleiche Signatur haben."

"Not the same signatur"

You not only get the State Event object but a second object which refers to the handler which triggered the state event...

"Public Event LFSState(sender As FullMotion.LiveForSpeed.InSim.InSimHandler, e As FullMotion.LiveForSpeed.InSim.Events.State)"

The bold part is new in the X version and was not in previous versions.
Are you using VB6 or VB.NET? Because your code snippet is not syntaxically correct for VB.NET with .NET 2.0. As far as I know, you can't use .NET libraries with VB6...

Anyways, here's a code snippet of a working VB.NET program that does what yours is attempting to do:


[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] FullMotion.LiveForSpeed.InSim
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] FullMotion.LiveForSpeed.InSim.Enums
[/SIZE][SIZE=2][COLOR=#0000ff]Module[/COLOR][/SIZE][SIZE=2] Module1
[/SIZE][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]WithEvents[/COLOR][/SIZE][SIZE=2] Handler [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] InSimHandler
[/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Main()
ConnectToLFS([/SIZE][SIZE=2][COLOR=#a31515]"127.0.0.1"[/COLOR][/SIZE][SIZE=2], 29999, [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2])
Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Press Enter to Exit"[/COLOR][/SIZE][SIZE=2])
Console.ReadLine()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ConnectToLFS([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] IP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Port [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Password [/SIZE][SIZE=2][COLOR=#0000ff]as[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]Handler = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] InSimHandler
Handler.Configuration.LFSHost = IP
Handler.Configuration.LFSHostPort = Port
Handler.Configuration.UseTCP = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'This is not needed for use with TCP
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'Handler.Configuration.ReplyPort = 30000
[/COLOR][/SIZE][SIZE=2]Handler.Configuration.Local = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2]Handler.Configuration.ProgramName = [/SIZE][SIZE=2][COLOR=#a31515]"InGame"
[/COLOR][/SIZE][SIZE=2]Handler.Configuration.AdminPass = Password
Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Try to connect"[/COLOR][/SIZE][SIZE=2])
Handler.Initialize()
Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Connected"[/COLOR][/SIZE][SIZE=2])
Handler.RequestState()
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
Handler = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing
[/COLOR][/SIZE][SIZE=2]Console.WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Failed to connect "[/COLOR][/SIZE][SIZE=2] & vbCrLf & ex.Message)
[/SIZE][SIZE=2][COLOR=#0000ff]Return
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Handler_LFSState([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] InSimHandler, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] FullMotion.LiveForSpeed.InSim.Events.State) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Handler.LFSState
Console.WriteLine(e.Weather)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Module[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]

[/COLOR][/SIZE]
Thx....that worked.

Here´s the same position from last Version. I tried to make it the same way.

[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] InSimHandler_Updated([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] InS [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] InSim.Events.State) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] InSimHandler.LFSState[/SIZE]

[SIZE=2] Weather = InS.Weather[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

You are a victim of this little insidious statement from the release notes:
Some events lost or gained information as the underlying data structures changed

Basically, as I did the various clean-ups necessary for going to patch X, I also brought all events into line the standard .NET event syntax, so that any event could get handled with a plain EventHandler delegate. So since 0.12b all events now always have a sender and eventargs that inherit EventArgs.

You need to change your eventhandler from

PrivateSub InSimHandler_Updated(ByVal InS As InSim.Events.State) Handles InSimHandler.LFSState


to

PrivateSub InSimHandler_Updated(ByVal sender As InSimHandler,
ByVal InS As FullMotion.LiveForSpeed.InSim.Events.State) Handles InSimHandler.LFSState


That should do the trick
Thx.

Going to see what´s else new.
If I hook up an event to


handler.RaceTrackRaceEnd += new RaceTrackRaceEndHandler(OnInSimRaceEnd);

The resulting RaceTrackRaceEnd parameter appears to have only the base object methods, E.G. ToString(), Equals() etc... Maybe I'm doing something wrong, but I tried it in a couple of different ways. Unless of course that class is supposed to have no properties or methods.
Quote from DarkTimes :The resulting RaceTrackRaceEnd parameter appears to have only the base object methods, E.G. ToString(), Equals() etc... Maybe I'm doing something wrong, but I tried it in a couple of different ways. Unless of course that class is supposed to have no properties or methods.

That is actually correct. The Race end packet is really an IS_TINY with TINY_REN type, i.e. it carries no extra information. Creating an eventargs for that event was kind of redundant. I could have just used EventArgs.Empty, but wanted to have an EventArgs object in case that there might be information in the packet in the future.
Ah, OK. That makes sense.

I do have to say that this is the first time I've used your library and I do find it very easy to use and very powerful. I greatly appreciate the huge effort that you've put into developing it.

LFSLib.NET 0.14b
(11 posts, started )
FGED GREDG RDFGDR GSFDG