*Rebooting a question because I received no feedback; did original post a
month ago.
Using Gnoga for a multiplayer game, I have a question which I fail to
answer myself because I do not know a) enough about Ada and b) enough about
the architecture of Gnoga/Simple Components stack.
- note1: A match is two players connected through webRTC.
- note2: To establish a webRTC connection between those two players I have
to relay some messages to one another, without delay.
This sample code is a subset of what I have done to relay messages from one
player to the other. My question is about the eventual outcome of one
player disconnecting while Relaying. Let suppose the 'other' player is
killing its browser.
----------------------------
procedure Relay_Signal (App_Data : in App_Data_Access; Value : String) is
Other_App_Data : App_Data_Access := Control.Find_Other(App_Data);
begin
if Other_App_Data /= null then
My_Game.Controller.Relay_Message(Other_App_Data, Value);
end if;
end Relay_Signal;
protected Control is
function Find_Other (App_Data : App_Data_Access) return
App_Data_Access;
private
Matchs : Matchs_Vec.Vector;
end Control;
protected body Control is
function Find_Other (App_Data : App_Data_Access) return
App_Data_Access is
begin
if App_Data.Match_Index_Is_Valid then
for Player of Matchs.Element(App_Data.Match_Index).Players loop
if Player /= App_Data then
return Player;
end if;
end loop;
end if;
return null;
end Find_Other;
end Control;
-----------------------------
I suppose that in the worst case: Other_App_Data is found and returned from
Find_Other but that other player is disconnected (Other_App_Data becomes
invalid) just before My_Game.Controller.Relay_Message(Other_App_Data,
Value) is called. What I think will happen is just an exception thrown when
I am manipulating Other_App_Data inside Relay_Message.
1) Am I right? If so is it OK?
2) Else, why and how should I handle such a case?
Thx,
Olivier
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list