示例#1
0
        /// <summary>Create an instance of the <see cref="Connection"/> service.
        /// </summary>
        /// <param name="stream">The connection stream.</param>
        /// <param name="onRectangle">The action to take when a rectangle is received.</param>
        /// <param name="onStateChange">The action to take on a state change.</param>
        /// <param name="onException">The action to take on an exception.</param>
        /// <returns>The operations instance used to communicate with the service.</returns>
        public static ConnectionOperations CreateFromStream(Stream stream, Action<Rectangle> onRectangle, Action<ConnectionState> onStateChange, Action<Exception> onException)
        {
            var connection = new Connection(stream, stream, onRectangle, onStateChange, onException);

            connection.Init();

            return connection;
        }
示例#2
0
        /// <summary>Create an instance of the <see cref="Connection"/> service.
        /// </summary>
        /// <param name="streamSocket">The connection stream.</param>
        /// <param name="onRectangle">The action to take when a rectangle is received.</param>
        /// <param name="onStateChange">The action to take on a state change.</param>
        /// <param name="onException">The action to take on an exception.</param>
        /// <returns>The operations instance used to communicate with the service.</returns>
        public static ConnectionOperations CreateFromStreamSocket(StreamSocket streamSocket, Action<Rectangle> onRectangle, Action<ConnectionState> onStateChange, Action<Exception> onException)
        {
            var readStream = streamSocket.InputStream.AsStreamForRead();
            var writeStream = streamSocket.OutputStream.AsStreamForWrite();
            var connection = new Connection(readStream, writeStream, onRectangle, onStateChange, onException);

            connection.Init();

            return connection;
        }