New Version is Ready  

PokeIn v2.225! 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 both 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. Probably you already experienced that IIS has some limitations with comet ajax or similar approaches. Before going into details, we assure you that we have implemented many built-in smart solutions to get rid of these issues. As long as you stick with the basic rules advised on our Advanced tutorials, you may assume PokeIn handles most of the hard stuff for you. If you are developing .NET 2.0/3.5 application, consider using IIS Tuner software for even better performance under IIS. ( .NET 4.0 +  Application pool may not require tricks applied by IIS Tuner)

Basic Dynamic Bind

With 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 limited with the IIS etc. environment limitations. Although we don’t advice this usage for everyone, it can be a good start for developers not experienced with PokeIn. Remember; you shouldn't use basic handler on any serious application. (PokeIn Upload Control requires basic handler but you may limit basic handler usage only with upload control)

There are only 2 steps you have to take in order 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 into 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 important difference with the second usage is; you are free to decide to the connection of time on the client side.  Now, we have to define server side handler target to let 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 the file name same with the name in above script tag)

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

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


That's it. You have a basic handler for the calls from clients. Above code enables ASP.NET session state in read only mode. In case you don’t need ASP.NET session states, you can assign it to “False” but it can't be “TRUE”.

Now, it is time to define server side onClientConnected event listener; On this event, PokeIn will be asking for client specific component/object you prefer to use. Remember; the public methods defined on this object will be publicly accessible from the client side.

    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));

        }

When a new client connects  to server, PokeIn makes all the public (void/procedure) methods of Dummy class available on client side. In case you have a question regarding to usage of Basic Handler, please check our “Basic Tutorial” and sample project at the bottom of the page.

Dynamic Bind under HTTP Handlers (Advanced Handler)

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

PokeIn HTTP Handlers

               

As we mentioned on above image, PokeIn helps you to create real life solutions in a much more scalable way. Actually, there are very few things you have to do in order to activate dynamic handling over the 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 depends to your server software type under web.config -> configuration ; (our FREE Edition pack demonstrates samples for varying use cases)

  <!-- 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>

Congratulations! Now you have upgraded your web application into the real life capabilities. In case you couldn't manage to make dynamic handler working, better download the FREE Edition package and check the sample projects using dynamic handlers.

Sleep Mode Connections

Some of the web applications may not need to have server push functionality but still require features PokeIn offers. The only thing you need to do is activating SleepMode from the web.config.(or CometSettings)

<!—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 when SleepMode is active.

Cross Domain Support

PokeIn Gold, OEM, and CUBE edition owners can benefit from unlimited cross browser, cross domain support by enabling it from CometSettings.CrossDomain property. Please also keep in mind you need below ASP.NET web.config configuration made properly. Under <system.webServer> paste the below lines in order;

<httpProtocol>
        <customHeaders>
          <add name="Access-Control-Allow-Origin" value="*" />
          <add name="Access-Control-Allow-Headers" value="Content-Type" />
        </customHeaders>
</httpProtocol>

One more thing to remember is, properly defining the HandlerTarget from the CometSettings or corresponsing Web.config part. Normally you only define the name of the advanced handler like "PokeIn.ashx" or "r.PokeIn" etc. but this time, it requires you to set the full URL:

<add key="PokeIn_HandlerTarget" value="http://yourdomain.com/h.PokeIn" />

Chunked Listener

Enabling PokeIn's chunked listener makes 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 same 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)


PokeIn ASP.NET WebSocket & Reverse Ajax Library .NET 2+, Mono 2.4+ Compatible!
  • Reverse Ajax & Server Push
  • Hybi00, Hybi10, Hybi17 RFC 6455 WebSocket Server
  • Intelligent Fail Recovery
  • Desktop Client Support
  • Java Client (Linux, OSX, Android, Embedded)
  • Objective-C Client ( IOS, OSX )
  • Secured Message Encoding (both sides)
  • Clone Message Attack Protection
  • Content Resource Manager / Delivery
  • ASP.NET MVC Compatible
  • Mono Runtime Support
  • Session Cloning Detection
  • Thread Safe Object Managers
  • Client Disconnection Detection
  • Apache 2.2+, Nginx, IIS 5+Compatible
  • 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
  • Load Balancer Support
  • Multi Core Management
  • Azure, EC2 etc. Compatible
  • Lightweight and cross-browser (150+ browser versions)
    (IE, FireFox, Safari, Opera, Chrome, IOS, Android, ....)
  • WCF & .NET Remoting Support
  • Unlimited Concurrent Connections (Cluster Support)

Copyright 2013 Zondig

Privacy Statement|Terms Of Use