我有一個多人紙牌遊戲(最多4名玩家可以玩同一個遊戲實例)在Facebook上。 遊戲很小,託管在一臺服務器上。 我正在研究可伸縮性,因爲我希望很快就會有一臺服務器不夠。Azure:關於製作簡單多人紙牌遊戲可擴展的建議
在存儲器服務器存儲的哪個正在進行的所有遊戲的列表:List<Game>
當客戶端的請求(例如拋出一個卡)它發佈消息到服務器。 現在來了棘手的部分。 服務器不會立即發送響應,而是保持檢查其他玩家是否在回覆前修改了遊戲狀態。 這種方法工作得很好,因爲客戶端(silverlight)不會不斷地輪詢服務器。
你會推薦我在Azure中採用什麼方法?我的主要優先事項是快速響應客戶,避免客戶不斷進行輪詢。
用我有限的知識天青我想帶這條道路:
存放在Azure Table中,而不是存儲在內存中的遊戲。
這將在webrole來完成: 僞代碼:
void Page_LoadOfAnAspxPage
{
// deserialze the message from the posted information
Message msgClient = ...;
// retrieve game from table storage
Game g = RetrieveFromTableStorage(gameGuid);
// post message to game
g.ProcessClientMessage(msgClient);
// save back to table storage so other game clients can be aware of new state
SaveToTableStorage(gameGuid, g);
// now wait until another client modifies the game
while(true) // will I be incurring hosting charges (transactions for what is going on in this while loop)???
{
// grab game from table storage
g = RetrieveFromTableStorage(gameGuid);
// has something changed?
MsgResponse response = g.ProcessClientMessage(msgClient);
if (response.ActionName != ActionName.GameHasNotChanged)
{
// some other client changed the game.
// give this response back to our client
break;
}
// sleep a little and check again...
Sleep(xx);
}
}
你相信這種方法是否行得通呢?我可能遇到任何障礙嗎? 我會很感激任何建議/改進。
謝謝!
santiago