Пример #1
0
        /// <summary>
        /// Waits for a message to be received
        /// </summary>
        /// <typeparam name="T">Message type</typeparam>
        /// <returns>The message type</returns>
        /// <param name="timeout">The timeout in milliseconds</param>
        public T WaitForServerEvent <T>(int timeout) where T : IServerEvent
        {
            MessageReceivedEvent messageEvent = new MessageReceivedEvent();

            m_MessageAwaiters.Add(typeof(T), messageEvent);
            messageEvent.WaitForMessage(timeout);
            T eventResult = (T)messageEvent.Message;

            messageEvent.Dispose();
            m_MessageAwaiters.Remove(typeof(T));

            return((T)messageEvent.Message);
        }