where can I write standalone serverside actions in LiteLobby

Options
Paresh
edited November 2011 in Photon Server
hi,
I want to send notification from server to all actors in a room to take them some actions. but I am bit confused where I can put it on server side, it's not dependent on any of the client's action so I can't write it in OnOperationRequest of LiteLobbyPeer class. I want to make it independent of client's interaction.

Can you please help me understanding the implementation for it? in which class I can do it? :?

thanks

Comments

  • Hi Paresh,
    the LiteLobbyRoom is the class you are looking for.

    What condition triggers your notification? Is it done by a timer, perhaps? In that case, you could have a look at the implementation of the "SchedulePublishChanges" method, which schedules regular notifications for all clients in the room. Also have a look at "ProcessMessage", where the scheduled notifications are actually sent.

    Hope this gives you a good starting point - if you need further advice, let us know!
    - Nicole
  • thanks for your reply... I will work around it.

    while waiting for your reply, I checked above mentioned methods to use but decided to try experimenting with ScheduleMessage first. also I tried working with
                                    var message = new RoomMessage((byte)LobbyMessageCode.PublishStartGame);
                                    this.State.Room.ScheduleMessage(message, 200);
    

    but not able to find how it will get collected at client side.

    So I will try using your mentioned methods first then will back to this.
  • hi Nicole,

    i did study LiteLobbyRoom class & SchedulePublishChanges, ProcessMessage methods.
    but I end up implementing it in LiteGame.cs class in side ProcessMessage method, because it's not going to the ProcessMessage of LiteLobbyRoom class(i did debugging).

    i am calling it inside LiteLobbyPeer.cs after receiving clients response on particular task:
                                    var message = new RoomMessage((byte)GameMessageCodes.PublishStartGame);
                                    this.State.Room.ScheduleMessage(message, 3000);
    

    Is it fine or I should change implementation of it from LiteGame class to LiteLobbyRoom class along with following states:
    LiteLobbyRoom.cs
    
             protected override void ProcessMessage(IMessage message)
            {
                // this switch only handles the Lobby-specific messages.
                // all other messages will be handled by the base class. (which is class LiteGame where I written current logic)
                
                switch ((LobbyMessageCode)message.Action)
                {
                    case LobbyMessageCode.AddGame:
                        this.GameListAddOrUpdateGameId((string[])message.Message);
                        return;
    
                    case LobbyMessageCode.RemoveGame:
                        this.GameListRemoveGameId((string[])message.Message);
                        return;
    
                    case LobbyMessageCode.PublishChangeList:
                        this.PublishChangeList();                    
                        return;
                }
                base.ProcessMessage(message);
            }
    

    problem in doing this is calling from LiteLobbyPeer.cs of
    this.State.Room.ScheduleMessage(message, 3000);
    

    how can call any method written inside of LiteLobbyRoom.cs since not able to collect any instance of it inside LiteLobbyPeer?

    may be I am missing something.
    or is it okay what I am doing now since it working fine, or is it bad programming practice?

    your guidance will be really appreciated.

    thanks,
    Paresh
  • Tobias
    Options
    The LiteLobbyRoom IS a LiteGame, so you could schedule messages the same way you do in LiteGame. Its a specialized version, which should be used by the LiteLobby application.

    So the question is why you never end up in LiteLobbyRoom.
    You could try to find that out, as you have all the source necessary. I can't promise when we have the time to investigate.
  • thanks Tobias, I did debug it many times & try to find out why it's not going in LiteLobbyRoom but didn't come up with solution, so decided to move ahead with it for now since I don't have much time to spend on it. will put up extra time later & if found something then will post here.
  • Tobias
    Options
    Thank you for letting me know. I will put this into our queue and hopefully we can find something while you concentrate on your game.
  • BenStahl
    Options
    I have just ckecked the server side code. The ProcessMessage method of the LiteLobbyRoom class is called after an message is enqueued using the ScheduleMessage method.
    Maybe there is a little confusion about the dufferent Room implementations in the LiteLobby project.
    The LiteLobbyRoom class is used for lobby instances and the LiteLobbyGame class for game instances. The LiteLobby project has it's own JoinRequest implementation witch inherits from the Lite JoinRequests and extends it which the LobbyId property.
    Have a look at the HandleJoinOperation method of the LiteLobbyPeer class to see which kind of class will be instantiated when handling the join operation with GameId and LobbyId set to different values.