Sorry, I haven't had time for any off-work programming lately. I'll let you know as soon as I do test them though.
[B]Message[/B]: Index was outside the bounds of the array.
[B]Source[/B]: InSimDotNet
[B]StackTrace[/B]: at InSimDotNet.EncodingHelper.GetBytes(String value, Byte[] buffer, Int32 index, Int32 count)
at InSimDotNet.Packets.PacketWriter.Write(String value, Int32 length)
at InSimDotNet.Packets.IS_BTN.Pack()
at InSimDotNet.InSim.Send(ISendable packet)
at Dizplay_Cruise.Button.Processor.QueueProcessor_Elapsed(Object source, ElapsedEventArgs e) in D:\Loran\Programming\C#\Live for Speed\Dizplay\Cruise A.0.1\Dizplay Cruise\Dizplay Cruise\Button\Processor.cs:line 35
at System.Timers.Timer.MyTimerCallback(Object state)
// To delete one button.
insim.Send(new IS_BFN
{
SubT = ButtonFunction.BFN_DEL_BTN,
ClickID = 1, // ID of button to delete
UCID = 0, // User to delete the button for
});
// Delete them all
insim.Send(new IS_BFN
{
SubT = ButtonFunction.BFN_CLEAR,
UCID = 0, // User to delete the buttons for
});
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at InSimDotNet.Packets.PacketWriter.Write(String value, Int32 length)
at InSimDotNet.Packets.IS_BTN.Pack()
at InSimDotNet.InSim.Send(ISendable packet)
at DriftProject.Button.Control.NewButton(Vars Conn, Int32 currentID, IS_BTN Button) in G:\Users\Povilas\documents\visual studio 2010\Projects\DriftProject\DriftProject\Button\Control.cs:line 20
at DriftProject.Packets.MCI.Update(Vars Conn) in G:\Users\Povilas\documents\visual studio 2010\Projects\DriftProject\DriftProject\Packets\MCI.cs:line 50
UF1 XFG ^7XRG LX4 LX6 RB4 ^8FXO XRT ^7RAC ^8VWS FZ5 ^7UFR XFR FXR XRR FZR ^8MRT
// 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..
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.
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.
public class CustomPacketFactory : IPacketFactory {
public IPacket BuildPacket(byte[] buffer) {
// Implement your own packet handling code here. You can
// create your own packets or do whatever you need to,
// so long as your new packet inherits from IPacket.
return null;
}
}
InSim insim = new InSim();
// Set your custom packet factory
insim.PacketFactory = new CustomPacketFactory();
// Exists here normal InSim.NET code...
public class CustomSocket : ISocket{
// Custom implementation of ISocket.
}
InSim insim = new InSim();
// Set your custom socket.
insim.Socket = new CustomSocket();
// Whatever...
InSim insim = new InSim();
// You have complete access to underlying socket.
insim.Socket.PacketDataReceived += insim_PacketDataReceived;
private void insim_PacketDataReceived(object sender, PacketDataEventArgs e) {
// Now you have raw byte data...
byte[] data = e.GetData();
}
// You can access the underlying socket without the InSim abstraction
TcpSocket sock = new TcpSocket();
// It handles the TCP receive stream for you, basically makes TCP act like UDP...
sock.PacketDataReceived += insim_PacketDataReceived;
// You can create a connection.
sock.Connect("127.0.0.1", 29999);
// And send raw packets...
sock.Send(new IS_ISI {
Admin = String.Empty;
IName = "Test!",
}.Pack());
private void insim_PacketDataReceived(object sender, PacketDataEventArgs e) {
// And handle them however you like...
byte[] data = e.GetData();
}