New Version is Ready  

PokeIn v1.618! is ready for action!
Click here to read changelog & download
the latest library.

 

FREE Community Edition  

Free, feature rich community edition available!
Visit editions page to see the details of our free community version..

 

Any Question?  

Click here to visit our Frequently Asked Questions page or visit Discussions section to ask your own questions to the community and our professionals.

 

PokeIn Advanced Tutorial  

                PokeIn provides the efficient and comprehensive communication channel between the server and client sides. Moreover, it manages your static and dynamic server side resources and helps you to create memory and CPU efficient web applications. Although the comet ajax approach covers most of the web application communication needs, there will be differences in the use cases. Thus, we have implemented more than a one option you may use in your application to give a chance to create scalable, feature rich web applications for your customers.

                IIS has known limitations with comet ajax approach in normal usage or under simple implementations. Before delve into the details, we assure you that we have implemented many built-in smart solutions to get rid of these issues.So, PokeIn handles the required work internally for you. For example, PokeIn caching class is based on an entirely unique structure and PokeIn doesn’t use the thread pool of IIS. Additionally, you should use our IIS Tuner software for even better performance under IIS as soon as possible.

                In this long article, we want to share with you the each concept of PokeIn in details. It would be nice, if you read this article line by line before any decision of implementation.

Basic Dynamic Bind

                In this approach, PokeIn uses and holds each connections’ internal thread to keep the connection alive. This is a very basic usage of comet ajax approach and your application is strictly bound with IIS and the environment limitations. Although we don’t advice this usage for everyone, it can be a good start for the simple applications.

                There are only 2 steps you have to do to make your application is running under Basic Dynamic Bind. At first, put the client side codes in a right place as we shown below. Please notice that, the client side implementation is the same for all the connection types we are going to mention.

Put the below line to the page you need PokeIn support;

                <script type="text/javascript" src="Handler.aspx?ms=connect"></script>

                Also, you will need to call PokeIn.Start method to start a connection request to the server as shown below;

<body> 

    <script>

        //PokeIn automaticly starts when detects a listener on document.OnPokeInStart

        document.OnPokeInStart = function (status) {

            if (status == true) {

                //PokeIn is started!

            };

        };

This is not the only way to start a connection from the client side, you may use the below alternative regarding to your implementation;

<body> 

    <script>

        //PokeIn automaticly calls the below listener when it is ready

        document.OnPokeInReady = function () {

            PokeIn.Start(function(status){

                if (status == true) {

                    //PokeIn is started!

                };

            };

        };

The main difference in the second usage is that you are free to decide to the connection time on the client side.  Now, we have to define server side handler target for making PokeIn to create communication between the client and server sides. Thus, make sure that there is a “Handler.aspx” in your solution. (The file name could be anything, just make sure that it should be consistent with the name in above script tag)

<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="ReadOnly" %>

<% PokeIn.Comet.CometWorker.Handle(); %>

The above 2 lines will be enough in a very basic usage and there are only 2 rules for the handler targets. First, they must be calling Handle method from the CometWorker class and the second is, EnableSessionState parameter must be assigned to “ReadOnly”. If you don’t want to use ASP.NET session states, you can assign “False” to this parameter but it shouldn’t be assigned to “TRUE”. That is it. In a very basic level, your application is connected to the server. Please remember that these 2 rules are only for the Handler.aspx page, not for your entire application!

Now, it is time to define server side actions on each connection requests as shown below;

    public partial class _Default : System.Web.UI.Page

    {

        static _Default()

        {

            CometWorker.OnClientConnected += new DefineClassObjects(CWOnClientConnected);

        }

        static void CWOnClientConnected(ConnectionDetails details, ref Dictionary<string, object> classList)

        {

            classList.Add("Dummy", new Dummy(details.ClientId));

        }

This step is quite similar for the other connection types and you can find the real usage in one of our sample projects or read “Basic Tutorial”.

Dynamic Bind under HTTP Handlers

                This is the second connection approach you may choose and as you will see below, it is very easy to convert your existing “Basic Dynamic Binding” application to this one. Before delve into the implementation, it would be appropriate to show the main reason behind this approach and explain how PokeIn passes beyond the limitations of your web server;

PokeIn HTTP Handlers

               

                As we mentioned above image that PokeIn helps you to create real life solutions in a much more scalable way. Actually, there are very few things you have to do to activate handling mechanism of PokeIn Library.

                At first, under web.config -> appSettings define the handler target as shown below;

<!-- Defines a solid path for the Handler point, otherwise PokeIn tries to find it. This can be a problem under the environments that url redirection is active. On this sample, this setting points to HttpHandler of PokeIn. Look below to see how we define the HTTP Handler -->

                <add key="PokeIn_HandlerTarget" value="PokeIn.ashx"/>

                And now define the server side handler which based on your server type under web.config -> configuration ;

  <!-- Define PokeIn as a HTTP Handler. All the calls to PokeIn.ashx will be handled by PokeIn as shown in picture. The below setting is useful for IIS7. Check MSDN (http://msdn.microsoft.com/en-us/library/46c5ddfy.aspx) or Mono (http://www.mono-project.com/FAQ:_ASP.NET) to see the proper configurations for the other servers-->

  <system.webServer>

    <handlers>

      <add name="PokeIn_Handler" verb="*" path="PokeIn.ashx" type="PokeIn.Comet.PokeInHandler, PokeIn" preCondition="integratedMode" />

    </handlers>

  </system.webServer>

   If ASP.NET sessions are not enabled on your application, use "PokeInHandlerNoSession" instead the above one.

              Congratulations! Now you have upgraded your web application to the real life usage.

Sleep Mode Connections

                Some of the web applications don’t need to use the server push functionalities but also needs features that PokeIn offer. The only thing you need to do is activating SleepMode from the web.config.

<!—put the below line into the appSettings -->

<add key="PokeIn_SleepMode" value="true"/>

                Now, you have the same scalability and functionality in your application except the connections which held for a long time.  Please keep mind, you can call the functions from the server side but you can't push data to clients in this mode.

Cross Domain Listeners

                Browsers have some limitations regarding to connections you keep open to the same host. Especially, on IE6 and IE7, there are only 2 connections available for the same host. PokeIn helps you to manage this problem in the simplest way. Under web config -> appSettings;

<!-- Each target separeted from the other by semicolons -->

                <add key="PokeIn_ListenTargets" value="http://AAA.domain.com/Handler.aspx;http://BBB.domain.com/Handler.aspx"/>

                   It is very easy to manage subdomains on web servers, just make sure that the each target used by the same web application. In the above sample we have defined only 2 targets but you are free to define much more! Additionally, PokeIn watches the requests from the same sessions and ensures the different subdomains are used by the same client. In this way, a IE6 user can open your application more than a single window at the same time and it won't be a problem for him.

Chunked Listener

                     Benefiting from PokeIn chunked listener feature make your application is more resource friendly hence more efficient. Normally, on each request PokeIn renews the client listener connection. When you enable chunked listener option from CometSettings class, PokeIn will be using the listeners for many server push events. We would like to make this option TRUE by default but it may not work if you are using "Dynamic Content Compression" settings on your server or "Chunked" encoding mode is not available on your server software. We highly recommend you to use "ChunkedMode" for better server & client timings.

                     If you are planning to use ISA SERVER, make sure that it supports HTTP 1.1 and configured to use it in order to benefit from chunked mode. (Details available from http://technet.microsoft.com/en-us/library/cc302548.aspx)

Please keep in mind that we highly suggest you to install IISTuner and update your web application's pool to PokeIn for eliminating the limitations of IIS.

PokeIn Features  


ASP.NET Ajax development never been so easy ! .NET 2+, Mono 2.4+ Compatible!

Some of the key features:
  • Reverse Ajax & Server Push
  • Intelligent Fail Recovery
  • Desktop Client Support
  • Base64 Message Encoding (both sides)
  • Clone Message Attack Protection
  • 8, 16, 32+ Core Support
  • Sleep Mode and Cross Domain Listeners
  • Automated Object Level Joint Capabilities
  • Silverlight Support
  • Dynamic Connection Management
  • Complete .NET to JSON Serialization
  • Subscribe / Leave Channels
  • Event / Message Ordering
  • Multiple Server Support
  • Lightweight and cross-browser (IE, FireFox, Safari, Opera, Chrome, IOS, Android, ....)
  • Server CPU and Port usage friendly
  • WCF & .NET Remoting Support
  • Image & Video & Text Content Resource Manager
  • ASP.NET MVC Compatible
  • Mono Runtime Support
  • Session Cloning Detection
  • Thread Safe Object Managers
  • Secured Transfers
  • Client Disconnection Detection
  • Apache 2.2+, Nginx, IIS 5+Compatible
  • v1.614+ handles ~80K concurrent connections ( watch this video to see 11K result)
    You must !! Download & Install IIS Tuner on your server !!

Copyright 2012 zondig!

Privacy Statement|Terms Of Use