private void HandleSocket() { socket.On("new_drawing", (arg) => { }); socket.On("test_drawing", (arg) => { Application.Current.Dispatcher.Invoke((Action) delegate { Debug.LogOutput("recieved test_drawing event"); JObject obj = (JObject)arg; Point newPoint = new Point((double)obj.GetValue("point_x"), (double)obj.GetValue("point_y")); double thickness = (double)obj.GetValue("thickness"); byte r = (byte)obj.GetValue("r"); byte g = (byte)obj.GetValue("g"); byte b = (byte)obj.GetValue("b"); SolidColorBrush color = new SolidColorBrush(Color.FromRgb(r, g, b)); Ellipse newEllipse = new Ellipse(); newEllipse.Width = thickness; newEllipse.Height = thickness; newEllipse.Fill = color; newEllipse.Stroke = color; newEllipse.StrokeThickness = 1; ListPoint.Add(new EllipseModel(newEllipse, newPoint)); }); }); socket.On("new_slide", (arg) => { Application.Current.Dispatcher.Invoke((Action) delegate { JObject data = (JObject)arg; string roomId = data.GetValue("room_id").ToString(); string slide = data.GetValue("slide").ToString(); if (!currentRoom.ID.Equals(roomId)) { return; } // convert to image source CanvasBackground = ImageUtils.Base64StringToBitmapSource(slide); NotifyChanged("CanvasBackground"); Debug.LogOutput("Updated canvas background"); }); }); socket.On("new_image", (arg) => { Application.Current.Dispatcher.Invoke((Action) delegate { JObject data = (JObject)arg; string roomId = data.GetValue("room_id").ToString(); string image = data.GetValue("imgstring").ToString(); if (!currentRoom.ID.Equals(roomId)) { return; } // convert to image source CanvasBackground = ImageUtils.Base64StringToBitmapSource(image); NotifyChanged("CanvasBackground"); Debug.LogOutput("Updated canvas background"); }); }); }