0

I am working on unity with smartfox integration for my multi player cards game. Now I am creating rooms to join to play the game. Room is created and user is joined in the room, the problem is now I have to call USER_ENTER_ROOM event to confirm that user is entered in the room and no room creation error occurred. But this event is not givin the Logs. I have tried this

public void OnUserEnterRoom(BaseEvent evt){
    User user = (User)evt.Params["user"];
    Room room = (Room)evt.Params["room"];
    Debug.Log("User: " + user.Name + " has just joined Room: " + room.Name);
}

and I called this event in my awake function like this.

sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);

According to my r&d it should work but its not.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
allrounder
  • 49
  • 6
  • Whilst you may get an answer on SO there is also a GameDevelopment stack exchange where there may be more unity users.. I'd suggest trying there if you are unable to get help on here – Sayse May 15 '14 at 12:27
  • Oky gonna post there. – allrounder May 15 '14 at 12:33

1 Answers1

0

The USER_ENTER_ROOM event doesn't fire if you enter the room, but when another user enters a room you have already joined.

To confirm that you have joined the room and no error occurred you have to listen to ROOM_JOIN and ROOM_JOIN_ERROR.

If you need to create the room you can monitor ROOM_ADD and ROOM_CREATION_ERROR

Have a look at this tutorial: http://docs2x.smartfoxserver.com/DevelopmentBasics/join-and-create-rooms

Stefan Hoffmann
  • 3,214
  • 16
  • 30