public static void UpdateClient(string json) { ClientInfo client = JsonHelper.GetClientInfo(json); if (client.id.IsValid) { // Ignore info on ourself if (client.id.value == GlobalState.networkUser.id) { return; } if (client.room.IsValid) { // A client may leave the room if (client.room.value == "null") { GlobalState.RemoveConnectedUser(client.id.value); return; } // Ignore other room messages if (client.room.value != GlobalState.networkUser.room) { return; } // Add client to the list of connected users in our room if (!GlobalState.HasConnectedUser(client.id.value)) { MixerUser newUser = new MixerUser { id = client.id.value }; GlobalState.AddConnectedUser(newUser); } } // Get client connected to our room if (!GlobalState.HasConnectedUser(client.id.value)) { return; } MixerUser user = (MixerUser)GlobalState.GetConnectedUser(client.id.value); // Retrieve the viewId (one of possible - required to send data) MixerUser player = (MixerUser)GlobalState.networkUser; if (client.viewId.IsValid && null == player.viewId) { player.viewId = client.viewId.value; } if (client.userName.IsValid) { user.name = client.userName.value; } if (client.userColor.IsValid) { user.color = client.userColor.value; } bool changed = false; // Get its eye position if (client.eye.IsValid) { user.position = client.eye.value; changed = true; } // Get its target look at if (client.target.IsValid) { user.target = client.target.value; changed = true; } if (changed) { GlobalState.UpdateConnectedUser(user); } } }