public ChatRoomViewModel(MainViewModel mainVM, string ip, int remotePort, Server server) { this.mainVM = mainVM; this.server = server; uniqueID = (int)(GetHashCode() & 0xFFFFFFFC); myModel = new UserModel(uniqueID, mainVM.Name); client = new Client(ip, remotePort, uniqueID, this); client.SendData(ConvertClass.ObjectToByteArray(myModel), 0, uniqueID + 0); users = new List <UserModel>(); webcam = new Webcam((new FilterInfoCollection(FilterCategory.VideoInputDevice))[0]); webcam.NewFrame += (sender, e) => { if (myModel.IsScreenDemonstration != true) { client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1); } }; audioRecord = new AudioRecord(0); audioRecord.DataAvailable += (sender, e) => { client.SendData(e.Buffer, 0, uniqueID + 2); }; demonstration = new ScreenDemonstration(); demonstration.NewFrame += (sender, e) => { client.SendData(ConvertClass.ConvertBitmapToByte((Bitmap)e.Frame.Clone()), 0, uniqueID + 1); }; }