Updated: uploaded 1.0.10 with two bug fixes
I've uploaded version 1.0.9 to the first post, which has a few changes.
Anyway... you can now bind packets like this:
With this binding method Spark will pass a reference to the InSim instance that raised the packet event, so you can easily access the specific host a packet was sent from. This is useful, even required, when using a single program instance to manage multiple hosts.
In addition the two old Send(string message) and Send(string message, int ucid, int plid) have been replaced with a single method that uses C# 4.0 optional parameters. This method has the prototype Send(string message, int ucid=0, int plid=0). You can use it like so:
As I'm trying to maintain backwards compatibility I have left the old methods intact, but have marked them with obsolete attributes that will give you a friendly compiler warning when you use them. I have also obsoleted a few other small things that I plan one day to remove.
Please let me know if you have any problems.
I've uploaded version 1.0.9 to the first post, which has a few changes.
- Fixed bug in TCP send code, that could cause some weird issues in certain cases
- Added overridden Bind() method (see below)
- Added overriden Send() method for sending messages (see below)
- Obsoleted several old methods which will one day be removed
- Changed the internal socket used in TcpSocket and UdpSocket to be protected
- General code improvements
- Fixed bug with NullReferenceException when calling InSim.Dispose()
- Fixed bug with 'Spark.TcpSocket not connected' InSim error when calling InSim.Disconnect()
Anyway... you can now bind packets like this:
insim.Bind<IS_NCN>(NewConnection);
void NewConnection([b]InSim insim[/b], IS_NCN ncn)
{
// Pass.
}
With this binding method Spark will pass a reference to the InSim instance that raised the packet event, so you can easily access the specific host a packet was sent from. This is useful, even required, when using a single program instance to manage multiple hosts.
In addition the two old Send(string message) and Send(string message, int ucid, int plid) have been replaced with a single method that uses C# 4.0 optional parameters. This method has the prototype Send(string message, int ucid=0, int plid=0). You can use it like so:
// Send MST or MSX
insim.Send("Hello, InSim!");
// Send MTC to connection
insim.Send("Hello, you!", ucid: 0);
// Or send MTC to player
insim.Send("Hello, you!", plid: 0);
As I'm trying to maintain backwards compatibility I have left the old methods intact, but have marked them with obsolete attributes that will give you a friendly compiler warning when you use them. I have also obsoleted a few other small things that I plan one day to remove.
Please let me know if you have any problems.