Changes

Jump to navigation Jump to search
Line 160: Line 160:  
You should start by deciding how you want to layout your data. A good idea is to use the first byte to identify what type of message you are sending. You should also send a ping message to everyone in the start of a game, to check if other players also have the mod installed. You can use '''ParentMod.GetCurrentPlayers()''' to see who is currently connected (this includes the local player).
 
You should start by deciding how you want to layout your data. A good idea is to use the first byte to identify what type of message you are sending. You should also send a ping message to everyone in the start of a game, to check if other players also have the mod installed. You can use '''ParentMod.GetCurrentPlayers()''' to see who is currently connected (this includes the local player).
   −
The extension methods Software Inc. has for Stream objects include the ability to write strings, most simple types, like integers. They will be called ReadX or WriteX. It also has generic methods to write lists and dictionaries. If you implement the interface IByteData and add a static '''Type ReadData(Stream st)''' method, you can also quickly write that object using the Stream.Read/WriteByteObject extension methods. You can also use Stream.WriteObject to write arbitrary data, however this will quickly balloon in size and is very slow, so use it carefully,
+
The extension methods Software Inc. has for Stream objects include the ability to write any type you want, with simple types like ints, bools and strings having the best performance. They will be called ReadX or WriteX. It also has generic methods to write lists and dictionaries. If you implement the interface IByteData and add a static '''Type ReadData(Stream st)''' method, you can also quickly write that object using the Stream.Read/WriteByteObject extension methods. You can also use Stream.WriteObject to write arbitrary data, however this will quickly balloon in size and is very slow, so use it carefully,
    
== Full access ==
 
== Full access ==

Navigation menu