Page 1 of 1

OnPublicMessage callback is not working.

Posted: 25 Aug 2011, 08:48
by pankaj454k
Hi,
I m working on one Facebook game where i m using Unity. I am facing one problem to implementing chat. OnPublicMessage callback is not calling when i m sending msg to server.
Below code:

_smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);

public void OnPublicMessage(BaseEvent evt)
{
print("Chat message received");
}
public void OnChatMessage(string newMessage)
{
print("sending chat message " + newMessage);
_smartFox.Send(new PublicMessageRequest("Hello Everyone"));
}
Here I am calling OnChatMessage method as per my need.
Now my problem is OnPublicMessage has to call after sending msg to server but "OnPublicMessage" callback is not working. I have seen your given example. And I did exactly same but i don't know where m i doing mistake. Server side i can see the msg like "GenericMessage" when i type something on press enter. That means something happening there.
Please suggest me. I m facing this problem from last two days.

Posted: 25 Aug 2011, 11:17
by pankaj454k
Hi,
Now it is working. I was doing some mistake.
Thanks
pankaj

Posted: 25 Aug 2011, 11:19
by ThomasLund
Hi - this seems to be a SFS2X issue, right? This part of the forum is for the old SFS1.

But anyways - code looks good enough to me. The callbacks definitely work as you can see from the examples you also ran.

Some suggestions:
Do you remember to process the queue in a e.g. FixedUpdate()?
Can you log in and all the other stuff?
Are you joined in a room?

/Thomas