Last active
September 9, 2016 08:23
-
-
Save RobertPaulson90/377cd9ce192b85defac01fd285f9755e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sending client | |
private void UpdateServer() | |
{ | |
string headJSON = JsonConvert.SerializeObject(head); // head is class for the snake's head object | |
byte[] msg = Encoding.ASCII.GetBytes(headJSON); | |
int bytesSent = socketSender.Send(msg); | |
} | |
// Receiving-end socket listener | |
byte[] bytes = new byte[1024]; | |
int bytesRec = handler.Receive(bytes); | |
String headJSON = Encoding.ASCII.GetString(bytes, 0, bytesRec); | |
Head receivedHead = JsonConvert.DeserializeObject<Head>(headJSON); // Deserialization of "hard-coded" datatype |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment