Server & client method originator & destination questions

0 votes
Hi we have deployed AppWarpS2 server and database and now doing some testing.

I am looking through your code samples for quiz for Windows Phone and server codeand cannot understand where the desitnation is for client call JoinRoomWithProperties(). Is it in BaseServerAdapter handleAddUserRequest() as I notice the overriden method in the Windows Phone Quiz sample also retrieves the player fb friend list before invoking SendUpdatePeersNotification() to client.

So am I correct in thinking that the quiz sample client code JoinRoomWithProperties() (for random player game) is received on server in BaseServerAdapter() (which joins user to room or creates a room and joins user to it)? I can't see where in server code this method is handled because if it's in the overriden method handleAddUserRequest it doesn't do anything else with it as it for getting fb friend list!

Also where is the call back on client for the method JoinRoomWithProperties() as I notice that when quiz sample starts a random game it calls sendRequestPacket(STARTQUIZ) which is handled on server in QuizRoomAdapter.handleUpdatePeersRequest()  (which only increments StartQuizFlag by 1) but what callback method on client is invoked following a call to this method? I can't see which one deals with this cal back?

 

Many thanks I hope you can help me with these 2 questions.

 

Regards

TV
asked Jul 15, 2015 in AppWarpS2 by wiredvoltage (84 points)

2 Answers

+1 vote
 
Best answer

Hi,

- When client calls connect() api, it sends facebook details as authdata which is getting used on server in handleAddUserRequest to fetch the fb friends list who is playing this game and sends notification back to the user along with friends list.

- When you call JoinRoomWithProperties from the client, server handle the custom logic in handleUserJoinRequest method of class QuizRoomAdapter.

- On client side, onJoinRoomeDone callback defined in RoomReqListener class will be invoked in response of JoinRoomWithProperties API call.

Let us know if you face any problem.

Thanks.

 

answered Jul 17, 2015 by rajeev.etc (1,660 points)
selected Jul 17, 2015 by wiredvoltage
@rejeev Thats great stuff, exactly what I was hoping to hear - Many Thanks.

All is good and I have implemented gaming logic there. But when I play facebook friend during test and then try to play another game with same facebook friend I am getting error code 4 all the time (BAD_REQUEST) do you know what may be causing this? I though it might be that the room is still full or the users are still connected to room but I checked that I have removed them from room with WarpClient.GetInstance().LeaveRoom(GlobalContext.GameRoomId) - Many thanks.
Can you share which api is giving bad_request?

Some of the possible reasons of Bad_Request are:
- trying to join 2nd room without leaving from 1st room
- calling connect api but you are already connected etc.
- if the parameters passed to the request are invalid. For example if null or empty string is passed in the roomId parameter of a joinRoom request.
Hi rejeev the call is in MyProfile() following a fb.GetCompleted() event the call is: WarpClient.GetInstance().Connect(GlobalContext.localUsername, authString); I have checked the userName and authString for non null values. I have to also add that this does not always give an error code 4. Error code 4 is thrown when I retrieve a list of my fb friends and display them to the screen and press the hardware back button then try to play a new game with fb friends again.
I believe starting new game is calling connect() api. Pressing back button will not disconnect the user from server. Which means you are calling connect api with the user name whose session is already available on the server and this why it is considered as a Bad_Request by server.
Can you please try calling disconnect before starting new game and try?
Let me know if the problem continues.
0 votes

Hi,

Here are the description of the use cases that you have described :

  • handleAddUserRequest function calls when client calls connectWithUserName function. In this function you can write your business logic like you can fetch user profile or else.
  • JoinRoomWithProperties has no relation with handleAddUserRequest function.
  • If you want to write some business logic when user joins the room you can use handleUserJoinRequest in QuizRoomAdapter class. Similarly their are many methods you can override if you want to write your business logic.
  • In handleUpdatePeersRequest function we have written a business logic of quiz application.

Let me know if it helps.

Thanks

Vishnu Garg

answered Jul 16, 2015 by Vishnu Garg (674 points)
@ Vishnu thanks, so is there a client call back function from the call to JoinRoomProperties() as I can't see it - I also can't see the code in the sample to deal with the call for JoinRoomWithProperties() is it in BaseServerAdapter() ?

Can you answer these two questions for me - many thanks.
When you call JoinRoomProperties() you will get a callBack in onJoinRoomeDone function
@Vishnu thanks, so JoinRoomWithProperties() is called on server. But I notice in the sample that handleAddUserRequest() must be called sometime during a call to JoinRoomWithProperties() as this is where it gets their fb friend list. I assumed that a call to JoinRoomWithProperties() was invoked on server in BaseServerAdapter handleAddUserRequest() and is propagated onto handleAddUserRequest() in some way. Is this correct? If not then how does handleAddUserRequest() get called?

Thanks
@Vishnu, are you able to answer my query? You say that JoinRoomWithProperties() is not related to handleAddUserRequest() but it is invoked following a call to JoinRoomWithProperties() somewhere in your baseServerAdapter can you confirm where this is done eg is it done in the non overridden method of JoinRoomWithProperties() in this adapter?

Many thanks
Yes, Its called when you call connectWithUserName function from client side to connect with server
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...