public void DataProcessing(int userID, byte operation, byte[] data)
        {
            UserModel user = Users.Find(obj => obj.ID == (int)(userID & 0xFFFFFFFC));

            switch (userID & 3)
            {
            case 0:
                switch (operation)
                {
                case 0:
                    UserModel newUser = ConvertClass.ByteArrayToObject(data) as UserModel;
                    newUser.VoiceFrame = new AudioOutput();
                    Users = CollectionConversion.ConcatList <UserModel>(users, new List <UserModel>()
                    {
                        newUser
                    });
                    break;

                case 1:
                    Users = CollectionConversion.ConcatList <UserModel>(users, ConvertClass.ByteArrayToObject(data) as List <UserModel>);
                    foreach (var value in Users)
                    {
                        value.VoiceFrame = new AudioOutput();
                    }
                    break;

                case 2:
                    PropertyInfo property = ConvertClass.ByteArrayToObject(data) as PropertyInfo;
                    property.SetValue(user, !(bool)property.GetValue(user));
                    break;

                case 3:
                    mainVM.CurrentViewModel = new MenuViewModel(mainVM);
                    break;

                case 4:
                    Users = (ConvertClass.ByteArrayToObject(data) as List <UserModel>).FindAll(obj => obj.ID != uniqueID);
                    break;
                }
                break;

            case 1:
                if (user.IsWebcam != false || user.IsScreenDemonstration != false)
                {
                    user.CurrentFrame = new Bitmap(new MemoryStream(data));
                }
                break;

            case 2:
                if (MyModel.IsSpeaker)
                {
                    user.VoiceFrame.AddData(data);
                }
                break;
            }
        }
Example #2
0
        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;
            }
        }