Hi,

I've tried to play a hand on:
http://drupal-z2.pokersource.info/drupal6/ 

But I had the following error 50% of the time:
exceptions.AttributeError: Session instance has no attribute 'avatar'

After grepping the logs I found out that it was produced by the
following sequence server side:
* receive PacketPokerLongPoll
* receive PacketPokerGetPlayerInfo
* process PacketPokerGetPlayerInfo
* flush PacketPokerLongPoll
* return PacketPokerLongPoll
* updateSession (discard avatar)
* return PacketPokerGetPlayerInfo
* Traceback (avatar is already discarded)
* receive PacketPokerLongPollReturn
...

While it should be the following:
* receive PacketPokerLongPoll
* receive PacketPokerLongPollReturn
* flush PacketPokerLongPoll
* return PacketPokerLongPoll
* updateSession (discard avatar)
* return PacketPokerLongPollReturn
* no updateSession
* receive PacketPokerGetPlayerInfo
* createSession
* process PacketPokerGetPlayerInfo
* return PacketPokerGetPlayerInfo
* updateSession (discard avatar)

I figured out that jpoker-opensocial.xml was bypassing ajax_queue
mecanism by overriding $.ajax.

Which was preventing PacketPokerGetPlayerInfo to be queued until
PacketPokerLongPoll returns (because of PacketPokerLongPollReturn).

I patched ajax_queue to allow overriding the underlying $.ajax function:
changeset:   1779:ab32e196c4fc
tag:         tip
user:        r...@drupal-z2
date:        Fri Dec 11 21:22:32 2009 +0100
files:       jpoker/js/jquery.ajaxQueue.js
description:
allow ajax_queue original $.ajax override


diff -r c22f0117c55a -r ab32e196c4fc jpoker/js/jquery.ajaxQueue.js
--- a/jpoker/js/jquery.ajaxQueue.js     Tue Nov 24 12:45:15 2009 +0100
+++ b/jpoker/js/jquery.ajaxQueue.js     Fri Dec 11 21:22:32 2009 +0100
@@ -80,8 +80,6 @@
        // save the pointer to ajax to be able to reset the queue
        $.ajax_queue = $.ajax;
 
-       var ajax = $.ajax;
-       
        var pendingRequests = {};
        
        var synced = [];
@@ -100,9 +98,9 @@
                                        result = _error.apply( this, arguments 
);
                                 }
                                if (result === undefined) {
-                                       jQuery([ajax]).dequeue("ajax");
+                                       jQuery([$.ajax_queue]).dequeue("ajax");
                                } else {
-                                       ajax( settings );
+                                       $.ajax_queue( settings );
                                }
                        };
                        var _success = settings.success;
@@ -110,10 +108,10 @@
                                 if ( _success ) {
                                        _success.apply( this, arguments );
                                 }
-                               jQuery([ajax]).dequeue("ajax");
+                               jQuery([$.ajax_queue]).dequeue("ajax");
                        };
                
-                       jQuery([ ajax ]).queue("ajax", function(){
+                       jQuery([ $.ajax_queue ]).queue("ajax", function(){
                                 //
                                 // Allow cross domain requests when the 
protocol of 
                                 // an XmlHTTPRequest is not http. This must be 
done before each XmlHTTPRequest call,
@@ -127,7 +125,7 @@
                                 if(window.Components && window.netscape && 
window.netscape.security && document.location.protocol.indexOf("http") == -1) {
                                     
window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                                 }
-                               ajax( settings );
+                               $.ajax_queue( settings );
                        });
                        return undefined;
                case "sync":
@@ -166,7 +164,7 @@
                 if(window.Components && window.netscape && 
window.netscape.security && document.location.protocol.indexOf("http") == -1) {
                     
window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                 }
-               return ajax.apply(this, arguments);
+               return $.ajax_queue.apply(this, arguments);
        };
        
 })(jQuery);

And patched jpoker-opensocial.xml not to bypass ajax_queue:
changeset:   119:acdc35dc9778
tag:         tip
user:        r...@drupal-z2
date:        Fri Dec 11 21:22:02 2009 +0100
files:       jpoker-opensocial.xml
description:
makeRequest should not bypass ajax_queue


diff -r 55457d63e123 -r acdc35dc9778 jpoker-opensocial.xml
--- a/jpoker-opensocial.xml     Thu Dec 10 17:14:48 2009 +0100
+++ b/jpoker-opensocial.xml     Fri Dec 11 21:22:02 2009 +0100
@@ -7,32 +7,33 @@
      <![CDATA[ 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>jpoker sample application</title>
<--- snip --->
        <script language="JavaScript" type="text/javascript" 
src="/planc/js/jquery.query-2.1.6.js"></script>
        <script language="JavaScript" type="text/javascript" 
src="/planc/js/poker.js"></script>
        <script type="text/javascript">   
          var restURL = "http://"; + document.location.host + "/POKER_REST";
-         var jQueryAjax = $.ajax;
          var server;
+         var overrideAjax = function() {
+         var jQueryAjax = $.ajax_queue;
          $.jpoker.verbose = 6;
          $.jpoker.doReconnectAlways = true;
-         $.ajax = function(options) {
+         $.ajax_queue = function(options) {
                var params = {};
                var postData = {
                        packet: options.data
@@ -45,16 +46,16 @@
                params[gadgets.io.RequestParameters.HEADERS] = { Cookie: 
document.cookie };
                var callback = function(result) {
                        if (result.errors.length > 0) {
-                               if (result.errors[0] != "Error 404") {
-                                       $.ajax = jQueryAjax;
-                                       server.error(result.errors);
-                               }
+                               $.ajax_queue = jQueryAjax;
+                               server.error(result.errors);
                        } else {
                                options.success(result.data);
                        }
                };
                gadgets.io.makeRequest(options.url, callback, params);
          };
+         };
+
          $.jpoker.plugins.table.callback.display_done = function(element) {
          var req = opensocial.newDataRequest();
                var params = {};
@@ -78,6 +79,7 @@
                });
          };
          gadgets.util.registerOnLoadHandler(function() {
+               overrideAjax();
                $.poker.main(restURL);
                server = $.jpoker.serverCreate({ url: restURL });
                 var game_id = $.query.load(top.document.location + 
'').get('game_id');

While debugging I found out that Shindig:
- always return an empty 404 page on any curl errors
- hardcode CURL_TIMEOUT to 2 seconds

I reported a bug here:
https://issues.apache.org/jira/browse/SHINDIG-1245

And attached a patch that provide better curl configuration and error
reporting for BasicRemoteContentFetcher:
https://issues.apache.org/jira/secure/attachment/12427763/shindig_curl_error_report.patch

- It uses curl_err* functions to provide a comprehensive error message
to the client
- And introduces a new configuration variable "curl_request_timeout" in
container.php

I updated container.php to set curl_request_timeout to a value greater
than long_poll_timeout (30 seconds).

I updated "jpoker php integration guidelines" according to this changes:
http://pokersource.info/developers/specifications/howto-jpoker-with-php.html#Timeout

I've been finally able to play a few hands with latest poker-network and
jpoker version on:
http://drupal-z2.pokersource.info/drupal6/

-- 
Johan Euphrosine <pro...@aminche.com>
Development and services around Free Software
http://aminche.com/

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Pokersource-users mailing list
Pokersource-users@gna.org
https://mail.gna.org/listinfo/pokersource-users

Reply via email to