Exemplo n.º 1
0
        /// <summary>
        /// Reads an incoming message syncronously and blocks until it recieves one.
        /// </summary>
        /// <returns>The resulting incoming message.</returns>
        public static NetworkIncomingMessage <TPayloadBaseType> Read <TPayloadBaseType>(this IPacketPayloadReadable <TPayloadBaseType> readable)
            where TPayloadBaseType : class
        {
            if (readable == null)
            {
                throw new ArgumentNullException(nameof(readable));
            }

            return(readable.ReadAsync().Result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads an incoming message asyncronously.
        /// The task will complete when an incomding message can be built.
        /// </summary>
        /// <returns>A future for the resulting incoming message.</returns>
        public static Task <NetworkIncomingMessage <TPayloadBaseType> > ReadAsync <TPayloadBaseType>(this IPacketPayloadReadable <TPayloadBaseType> readable)
            where TPayloadBaseType : class
        {
            if (readable == null)
            {
                throw new ArgumentNullException(nameof(readable));
            }

            return(readable.ReadAsync(CancellationToken.None));
        }