Pushed a few more
changes to the repository, although not made a proper release yet.
Breaking Change:
As it's still a beta I've introduced a breaking-change, namely that you now send messages to InSim a bit differently. I really missed the old style of sending formatted messages, so I've reverted it back to the InSim.Send(string, params object[]) method of old.
// Send message
insim.Send("Hello!");
// Send formatted message
insim.Send("Hello, {0}", name);
// Send message to specific connection
insim.Send(ucid, "Hello!");
// Send formatted message to specific connection
insim.Send(ucid, "Hello, {0}", name);
// Send message to specific connection or player
insim.Send(ucid, plid, "Hello!";
// Send formatted message to specific connection or player
insim.Send(ucid, plid, "Hello, {0}", name);
// etc.. etc..
Here is a most general list of changes in the repository.
Changes- Can now set your own IPacketFactory and ISocket on the InSim class again, if you need to implement your own packet code (this is kinda advanced stuff, but very useful)
- Improved and optimized the string handling code (yay more fun!)
- Improved InSim.Send(IEnumerable<ISendable>) method, which allows you to batch send packets for improved performance (useful if you need to send lots of buttons or messages in one go) (see below)
- Rewrote BindingCollection, making it cleaner and faster (although not something most people will notice)
- Can now save/load InSimSettings (see below)
- Fixed a few really big bugs in OutSim and OutGauge code.
To save the InSimSettings:
InSimSettings settings = new InSimSettings {
Host = "127.0.0.1",
Port = 29999,
Admin = "Whatever",
};
// Save to XML
InSimSettings.Save(settings, "mySettings.xml");
// Load from XML
InSimSettings settings = InSimSettings.Load("mySettings.xml");
// The InSimSettings are saved and loaded from disk using the
// XmlSerializer class, which is simple but effective.
To batch send packets (for extra network performance):
insim.Send(new List<ISendable> {
new IS_MST { Msg = "Hello" },
new IS_MST { Msg = "World" },
new IS_MST { Msg = "How" },
new IS_MST { Msg = "Are" },
new IS_MST { Msg = "You?" },
});
// All these packets get sent in a single call, instead of five
// separate calls, improving network throughput.
It is almost finished now, I only have a couple of small changes left to consider before I release InSim.NET 2.0 final. As always I invite and encourage people to pull the latest revision from CodePlex and let me known of any issues before I push it out to the world.