PokeIn Library, as a communication interface between the client and server, requires some actions handled by specific event listeners in order to accept user connections or transfer the messages over Websockets or Comet Ajax.
By default, you may set the listeners for below events in order to make PokeIn is handling the clients. Before the explanation of events, we want to remind you to not to define them inside any non static procedure/function getting call many times in an application lifetime. Better define them under Application_Start procedure of Global.asax as shown in our sample projects. If you keep reading, you will also learn how to define event handlers from web.config.
CometWorker.OnClientConnected (mendatory event) : When a user hits to a page that using PokeIn, this event gets fired in order to define user specific objects and let you know 'someone' is at your 'door' (not inside)
CometWorker.OnClientCreated (optional event) : You accept the connection and define user specific object inside above 'OnClientConnected' event but you don't know whether that client is 'ready' or not. This event lets you know that client is ready and you may start sending messages from the server side.
CometWorker.OnClientDisconnected(optional event) : When a user is totally removed from the client list, this event fires. You may not send any messages to this client anymore. For this reason, if you need to do something during client's disconnection process, better you listen PokeIn.OnClose event from the client side. Besides, consider disposing the garbage from user object properly.
CometWorker.OnFirstJoint (mendatory for Joint feature) : When a joint receives the first user request this event gets fired in order to define joint specific objects
CometWorker.OnClientJoined (mendatory for Joint feature) : If a joint is already defined on server, this event gets fired for each following joint connection requests. Tip: Do not add user objects you already add during OnFirstJoint event. They all already available inside that classList.
CometWorker.OnReconnectionDecision (optional) : If you want to keep ClientID is same during user's ASP.NET session lifetime, listen this event and decide whether you accept its reconnection or not.
Using Web.Config to define Event Listeners ( multiple event handling )
If you don't have an access to Global.asax or don't sure where to define OnClientConnected event, then you may want to define PokeIn events under web.config (under configuration section) as shown below. Another nice to have with this approach is, having multiple listener definitions per unique caller name. Let's say you have multiple pages requires different handling of the events. One of your pages might be related to chat interface and other one could be online stock etc. things. In case your solution fits this or similar situation consider using unique caller names and define the listeners under web.config
<!-- Definition of this part is mendatory -->
<section name="PokeInTargets" type="PokeIn.CustomConfig.PokeInTargets, PokeIn" requirePermission="false"/>
Possible list of events are;
<add EventType="ClientConnected" StrongName="EventsFromConfig.FirstSample, EventsFromConfig" Handler="OnClientConnectedToFirst" UniqueName="First" />
<add EventType="ClientCreated" StrongName="EventsFromConfig.FirstSample, EventsFromConfig" Handler="OnClientCreatedToFirst" UniqueName="First" />
<add EventType="ClientConnected" StrongName="EventsFromConfig.SecondSample, EventsFromConfig" Handler="OnClientConnectedToSecond" UniqueName="Second" />
<add EventType="ClientCreated" StrongName="EventsFromConfig.SecondSample, EventsFromConfig" Handler="OnClientCreatedToSecond" UniqueName="Second" />
EventType is one of the above green values defining the type of event. StrongName is the target class holding Handler method. At last, UniqueName is the decisive parameter you are going to use on ms=connect query. For example, normally your connection routine would be "Handler.aspx?ms=connect". In order to target "OnClientConnectedToFirst" event handler, you need to update this routine to "Handler.aspx?ms=connect&evTarget=First"
Details are also available inside "MultiPage & EventsFromConfig" sample project. Please remember that you can't define OnReconnectionDecision or OnClientDisconnected event listener from web.config file.