private void DataProcess(TcpClient client, byte[] source) { var(userID, operation, data) = CollectionConversion.GetSenderInformation(source); switch (operation) { case 0: var listData = CollectionConversion.AddToEndArray(CollectionConversion.AddToEndArray(ConvertClass.ObjectToByteArray(clientInfo), new byte[] { 1 }), userID); client.GetStream().Write(listData, 0, listData.Length); clientInfo.Add(ConvertClass.ByteArrayToObject(data) as UserModel); break; case 2: UserModel user = clientInfo.Find(obj => obj.ID == BitConverter.ToInt32(userID, 0)); PropertyInfo property = ConvertClass.ByteArrayToObject(data) as PropertyInfo; property.SetValue(user, !(bool)property.GetValue(user)); break; } }
private void DataConversion(byte[] source) { var(userID, operation, data) = CollectionConversion.GetSenderInformation(source); chatRoomVm.DataProcessing(BitConverter.ToInt32(userID, 0), operation, data); }