comp.lang.ada
 help / color / mirror / Atom feed
* Question: Controlled data and user disconnection interaction (Gnoga)
@ 2017-06-15 21:50 Olivier Henley
  2017-06-29 13:06 ` Olivier Henley
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Henley @ 2017-06-15 21:50 UTC (permalink / raw)


FIRST: I know this question should be asked on the Gnoga channel but everybody there is here anyway + other qualified people so ...

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 infos 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_Signal(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_Signal(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_Signal.

1) Am I right? If so is it OK?
2) Else, why and how should I handle such a case?

Thx,

Olivier

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question: Controlled data and user disconnection interaction (Gnoga)
  2017-06-15 21:50 Question: Controlled data and user disconnection interaction (Gnoga) Olivier Henley
@ 2017-06-29 13:06 ` Olivier Henley
  0 siblings, 0 replies; 2+ messages in thread
From: Olivier Henley @ 2017-06-29 13:06 UTC (permalink / raw)


Not Controlled... I meant Protected. 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-29 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-15 21:50 Question: Controlled data and user disconnection interaction (Gnoga) Olivier Henley
2017-06-29 13:06 ` Olivier Henley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox