Ejemplo n.º 1
0
        /// <summary>
        /// Handles notifications from clients telling us that they've finished drawing a line.
        /// </summary>
        /// <param name="message">The message to handle.</param>
        protected async Task handleLineCompleteMessage(LineCompleteMessage message)
        {
            // If the line doesn't exist, then ignore it
            if (!manager.LineIncubator.LineExists(message.LineId))
            {
                Log.WriteLine("[NibriClient#{0}/handlers] Ignoring LineComplete event for line that doesn't exist", Id);
                return;
            }
            DrawnLine line = manager.LineIncubator.CompleteLine(message.LineId);

            if (CurrentPlane == null)
            {
                Log.WriteLine("[NibriClient#{0}] Attempt to complete a line before selecting a plane - ignoring", Id);
                await Send(new ExceptionMessage(
                               401, "Error: You can't complete a line until you've selected a plane to draw it on!"
                               ));

                return;
            }

            Log.WriteLine("[NibriClient#{0}] Adding {1}px {2} line", Id, line.Width, line.Colour);
            await Task.WhenAll(
                manager.BroadcastPlane(this, new LineCompleteReflectionMessage()
            {
                OtherClientId = Id,
                LineId        = line.LineId
            }),
                CurrentPlane.AddLine(line)
                );
        }