Exemple #1
0
        /// <summary>
        /// Sends the drawing event data to all users connected to the room.
        /// </summary>
        public static async Task AddDrawLineEvent(DrawLineEvent ev, string room)
        {
            // TODO: probably easier to just enqueue the event, then redraw later, locking the image data to avoid race conditions
            var roomData = Room(room);
            var path     = roomData.Path;

            path.MoveTo(ev.From.X, ev.From.Y);
            path.LineTo(ev.To.X, ev.To.Y);
            RedrawRoomImage(roomData);

            foreach (var connectionId in _roomToConnections[room])
            {
                await Connection(connectionId).DrawEvents.Writer.WriteAsync(ev);
            }
        }
Exemple #2
0
        /// <summary>
        /// A method called by a client when it wants to send us a drawing event.
        /// </summary>
        public async Task SendDrawLine(DrawLineEvent ev)
        {
            var room = ConnectionRoom;

            await AddDrawLineEvent(ev, room);
        }