Esempio n. 1
0
 /// <summary>
 /// Save the web context state objects.
 /// </summary>
 /// <param name="context">The current server context.</param>
 /// <param name="netContext">The current web context.</param>
 protected virtual void SaveNetContext(Nequeo.Net.Provider.ClientContext context, Nequeo.Net.NetContext netContext)
 {
     // Assign the state objects.
     context.UniqueIdentifier = netContext.UniqueIdentifier;
     context.ServiceName      = netContext.ServiceName;
     context.IsAuthenticated  = netContext.IsAuthenticated;
 }
Esempio n. 2
0
        /// <summary>
        /// Create the web context.
        /// </summary>
        /// <param name="context">The current client context.</param>
        /// <returns>The net context.</returns>
        protected virtual Nequeo.Net.NetContext CreateNetContext(Nequeo.Net.Provider.ClientContext context)
        {
            // If the context has not been created.
            if (context.ContextState == null)
            {
                // Create the new context.
                Nequeo.Net.NetContext netContext = new Nequeo.Net.NetContext();

                // Assign the current context.
                netContext.IsSecureConnection = context.IsSecureConnection;
                netContext.IsSslAuthenticated = context.IsSslAuthenticated;
                netContext.Port                = context.Port;
                netContext.ServiceName         = context.ServiceName;
                netContext.UniqueIdentifier    = context.UniqueIdentifier;
                netContext.IsAuthenticated     = false;
                netContext.IsStartOfConnection = true;
                netContext.SocketState         = context.SocketState;
                netContext.IsAsyncMode         = context.IsAsyncMode;
                netContext.ConnectionID        = context.ConnectionID;

                // Assign the request input stream and response output stream.
                AssignRequestResponseStreams(context, netContext);

                // Assign the current context.
                context.ContextState = netContext;
            }
            else
            {
                // Get the current context.
                Nequeo.Net.NetContext netContext = (Nequeo.Net.NetContext)context.ContextState;
                netContext.ServiceName         = context.ServiceName;
                netContext.UniqueIdentifier    = context.UniqueIdentifier;
                netContext.IsAuthenticated     = context.IsAuthenticated;
                netContext.IsStartOfConnection = false;

                // Assign the current context.
                context.ContextState = netContext;
            }

            // Return the request context.
            return((Nequeo.Net.NetContext)context.ContextState);
        }
Esempio n. 3
0
        /// <summary>
        /// On received action handler.
        /// </summary>
        /// <param name="context">The current client context.</param>
        private void OnReceivedActionHandler(Nequeo.Net.Provider.ClientContext context)
        {
            try
            {
                // Create the web context and set the headers.
                Nequeo.Net.NetContext netContext = CreateNetContext(context);

                // If the event has been assigned.
                if (OnNetContext != null)
                {
                    OnNetContext(this, netContext);
                }

                // Save the web context state objects.
                SaveNetContext(context, netContext);
            }
            catch (Exception)
            {
                // Close the connection and release all resources used for communication.
                context.Close();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Assign the request output stream and response input stream.
 /// </summary>
 /// <param name="context">The current server context.</param>
 /// <param name="netContext">The current web context.</param>
 protected virtual void AssignRequestResponseStreams(Nequeo.Net.Provider.ClientContext context, Nequeo.Net.NetContext netContext)
 {
     // Create the response and request objects.
     netContext.NetResponse = Nequeo.Net.NetResponse.Create(context.Response.Input);
     netContext.NetRequest  = Nequeo.Net.NetRequest.Create(context.Request.Output);
 }
Esempio n. 5
0
 /// <summary>
 /// Inject the current context provider.
 /// </summary>
 /// <param name="context">The provider context.</param>
 public NetContext(Nequeo.Net.Provider.ClientContext context)
 {
     _context = context;
 }