Object Serialization

Posts 1–2 of 2 · Page 1 of 1
Object Serialization
I'm making a multiplayer snake in C# but I'm getting stuck on the networking part.

my plan was to use TcpClient and TcpListener, I have the listener set up but I have no idea how I can the send snake struct or direction updates...
On google I found that I need to do object serialization, but I have no idea how it works.
I found working code but am unable to understand what they're doing so I don't want to use it.

If someone could find or make me a detailed tutorial on how to send my game data over the network that would be awsome.

Thanks in advance,
Hell_Demon

P.S. Yes, I code it in C#, but since that section is dead and VB code can easily be ported to C# i'm asking it here instead.
You can transfer snake directions by trimming the parameters. When you broadcast the message through server, append the parameter at the end. When the client will receive the data, trim the parameter, perform a check on it and execute the direction.

Code:
While CurClient.Connected
Dim IncomingMessage As String = StreamX.ReadLine

'Trim the parameter. For example trims 'Snake # 1 Says: /Go Up' and returns 'Go Up'

Dim parameter as string = IncomingMessage.Substring(IncomingMessage . Indexof("/")+1)
If parameter = "MoveLeft" Then
'Snake MoveLeft Code Here...
ElseIf parameter = "MoveUp" Then
'Snake MoveUp Code Here...
End If
End While
I think this is all you need to communicate direction between the client snakes. I could be wrong.
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us