ishikota / PokerServer

Poker server using websocket
1 stars 0 forks source link

DBのtransaction中にmessageの返事を受け取って,ゲームが進んでしまう #12

Closed ishikota closed 8 years ago

ishikota commented 8 years ago
Could not execute command from {"identifier"=>"{\"channel\":\"RoomChannel\"}", "command"=>"message", "data"=>"{\"action\" : \"declare_action\" , \"poker_action\" : \"fold\" , \"bet_amount\" : 0 , \"room_id\"    : 1 , \"player_id\"    : 1 , \"credential\" : \"fugafuga\"}"}) [NoMethodError - undefined method `state' for nil:NilClass]: /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel_delegate.rb:69:in `fetch_dealer' | /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel_delegate.rb:45:in `declare_action' | /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel.rb:19:in `declare_action' | /Users/kota/.rvm/gems/ruby-2.3.0@rails_5_0_beta_1/gems/actioncable-5.0.0.beta1/lib/action_cable/channel/base.rb:244:in `public_send' | /Users/kota/.rvm/gems/ruby-2.3.0@rails_5_0_beta_1/gems/actioncable-5.0.0.beta1/lib/action_cable/channel/base.rb:244:in `dispatch_action'

サーバ側でgame_stateのrelation_shipをinsertしてる最中にdeclare_actionを受け取って, room.stateがまだ作られてないため,nilになってるっぽい.

   (0.1ms)  begin transaction
  SQL (0.4ms)  INSERT INTO "game_states" ("state") VALUES (?)  [["state", "{\"config\":\"\\u0004\\bo:\\u000bConfig\\b:\\u0013@initial_stackii:\\u000f@max_roundi\\n:\\u0018@small_blind_amounti\\n\",\"table\":\"\\u0004\\bo:\\nTable\\t:\\u0010@dealer_btni\\u0000:\\u000b@seatso:\\nSeats\\u0006:\\r@players[\\u0007o:\\u0010PokerPlayer\\u000b:\\n@nameI\\\"\\tkota\\u0006:\\u0006ET:\\n@uuidI\\\")194db322-7133-4f65-af5e-3aea20de24eb\\u0006;\\fT:\\u000f@hole_card[\\u0007o:\\tCard\\u0007:\\n@suiti\\u0015:\\n@ranki\\u0013o;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u0007:\\u000b@stackid:\\u0016@action_histories[\\u0006{\\nI\\\"\\u000baction\\u0006;\\fTI\\\"\\nRAISE\\u0006;\\fTI\\\"\\u000bamount\\u0006;\\fTi\\nI\\\"\\tpaid\\u0006;\\fTi\\nI\\\"\\u000fadd_amount\\u0006;\\fTi\\nI\\\"\\u000bplayer\\u0006;\\fT{\\tI\\\"\\tname\\u0006;\\fTI\\\"\\tkota\\u0006;\\fTI\\\"\\tuuid\\u0006;\\fTI\\\")194db322-7133-4f65-af5e-3aea20de24eb\\u0006;\\fTI\\\"\\nstack\\u0006;\\fTidI\\\"\\nstate\\u0006;\\fTi\\u0000:\\u000e@pay_infoo:\\u0019PokerPlayer::PayInfo\\u0007:\\f@amounti\\n:\\f@statusi\\u0000o;\\n\\u000b;\\u000bI\\\"\\tmotu\\u0006;\\fT;\\rI\\\")d7626eb2-a230-4420-a9d2-a201975a8f66\\u0006;\\fT;\\u000e[\\u0007o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\fo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u0010;\\u0012i_;\\u0013[\\u0006{\\n@\\u0010I\\\"\\nRAISE\\u0006;\\fT@\\u0012i\\u000f@\\u0013i\\u000f@\\u0014i\\n@\\u0015{\\tI\\\"\\tname\\u0006;\\fTI\\\"\\tmotu\\u0006;\\fTI\\\"\\tuuid\\u0006;\\fTI\\\")d7626eb2-a230-4420-a9d2-a201975a8f66\\u0006;\\fTI\\\"\\nstack\\u0006;\\fTi_@\\u001ci\\u0000;\\u0014o;\\u0015\\u0007;\\u0016i\\u000f;\\u0017i\\u0000:\\n@decko:\\tDeck\\u0007:\\u000b@cheatF;\\u0018[5o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u000fo;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u000bo;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\to;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\no;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u000fo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\bo;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\fo;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u0007o;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u000fo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u0007o;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u0010o;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\fo;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u0011o;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u0012o;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\ro;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u0013o;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u000eo;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u0013o;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\bo;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u000eo;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\to;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u0012o;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\ro;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\no;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\to;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\bo;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u0011o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u000eo;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u0010o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u0007o;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\no;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\fo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u0013o;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u0011o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\no;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u0012o;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u000fo;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\u0010o;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u000eo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u000bo;\\u000f\\u0007;\\u0010i\\u0015;\\u0011i\\u000bo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\u0012o;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u000bo;\\u000f\\u0007;\\u0010i\\u0007;\\u0011i\\to;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\u0011o;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\ro;\\u000f\\u0007;\\u0010i\\r;\\u0011i\\bo;\\u000f\\u0007;\\u0010i\\t;\\u0011i\\r:\\u0014@community_cardo:\\u0012CommunityCard\\u0006:\\u000b@cards[\\u0000\",\"round_count\":1,\"round_manager\":{\"street\":0,\"agree_num\":1,\"next_player\":0},\"broadcaster\":{\"ask_counter\":1}}"]]
RoomChannel#declare_action({"poker_action"=>"fold", "bet_amount"=>0, "room_id"=>1, "player_id"=>1, "credential"=>"fugafuga"})
   (0.8ms)  commit transaction
  Room Load (0.2ms)  SELECT  "rooms".* FROM "rooms" WHERE "rooms"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
   (0.1ms)  begin transaction
  Player Load (0.1ms)  SELECT  "players".* FROM "players" WHERE "players"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
  Room Load (0.2ms)  SELECT  "rooms".* FROM "rooms" WHERE "rooms"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
  GameState Load (0.1ms)  SELECT  "game_states".* FROM "game_states" INNER JOIN "game_state_relationships" ON "game_states"."id" = "game_state_relationships"."game_state_id" WHERE "game_state_relationships"."room_id" = ? LIMIT ?  [["room_id", 1], ["LIMIT", 1]]
  GameState Load (0.1ms)  SELECT  "game_states".* FROM "game_states" WHERE "game_states"."id" = ? LIMIT ?  [["id", 116], ["LIMIT", 1]]
Could not execute command from {"identifier"=>"{\"channel\":\"RoomChannel\"}", "command"=>"message", "data"=>"{\"action\" : \"declare_action\" , \"poker_action\" : \"fold\" , \"bet_amount\" : 0 , \"room_id\"    : 1 , \"player_id\"    : 1 , \"credential\" : \"fugafuga\"}"}) [NoMethodError - undefined method `state' for nil:NilClass]: /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel_delegate.rb:69:in `fetch_dealer' | /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel_delegate.rb:45:in `declare_action' | /Users/kota/development/rails/poker_server/poker_server/app/channels/room_channel.rb:19:in `declare_action' | /Users/kota/.rvm/gems/ruby-2.3.0@rails_5_0_beta_1/gems/actioncable-5.0.0.beta1/lib/action_cable/channel/base.rb:244:in `public_send' | /Users/kota/.rvm/gems/ruby-2.3.0@rails_5_0_beta_1/gems/actioncable-5.0.0.beta1/lib/action_cable/channel/base.rb:244:in `dispatch_action'
  SQL (0.6ms)  INSERT INTO "game_state_relationships" ("room_id", "game_state_id", "created_at", "updated_at") VALUES (?, ?, ?, ?)  [["room_id", 1], ["game_state_id", 116], ["created_at", 2016-05-18 11:49:02 UTC], ["updated_at", 2016-05-18 11:49:02 UTC]]
   (0.6ms)  commit transaction
ishikota commented 8 years ago

とりあえず,変更した状態でclientと動きの確認ができたのでclose