July 2017
Beginner to intermediate
390 pages
10h 53m
English
The event that is being called, SocketConnectionCompleted, should of course consume the connection and send data on it. That is what it is all about. This is what it looks like:
void SocketConnectionCompleted(IAsyncAction action, AsyncStatus status)
{
if (status != AsyncStatus.Completed)
{
// Something went wrong.
// We should probably deal with this
_socket.Dispose();
_socket = null;
return;
}
// Read the data
using (var reader = new StreamReader(_socket.InputStream.AsStreamForRead()))
{
var data = reader.ReadToEnd();
var newCubePosition = JsonConvert.DeserializeObject<SomeDataStructure>(data);
spinningCubeRenderer.PositionHologram(
new Vector3(
newCubePosition.X,
newCubePosition.Y,
newCubePosition.Z));
}
}
The ...
Read now
Unlock full access