Hello,
I would like to know why OnPrivateMessage event doest not fired event I send the message to myself.
Here is the code :
// ----- ChatController.cs
private void SendChatMessage(String message)
{
SmartFoxClient client = NetworkController.GetClient();
client.SendPrivateMessage(message, client.myUserId);
}
// ----- NetworkController.cs
private void SubscribeEvents()
{
...
SFSEvent.onPrivateMessage += OnPrivateMessage;
}
public void OnPrivateMessage(string message, User sender, int roomId, int userId)
{
Debug.Log("User " + sender.GetName() + " sent the following private message: " + message);
}
SendPrivateMessage
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Found a bug in the API.
Replace in SmartFoxClient.cs with this
and private messages should work.
Will be added to next API release
Replace in SmartFoxClient.cs with this
Code: Select all
case SFSEvent.onPrivateMessageEvent:
if (SFSEvent.onPrivateMessage != null)
{
SFSEvent.onPrivateMessage((string)evt.GetParameter("message"), (User)evt.GetParameter("sender"), (int)evt.GetParameter("roomId"), (int)evt.GetParameter("userId"));
and private messages should work.
Will be added to next API release
-
- Posts: 61
- Joined: 16 Jan 2009, 14:48
Same Issue
The code you said to paste seems to already be exactly in the SmartFoxClient.cs file already.
What else should I look for?
Thanks!
EDIT
A followup test shows that the:
Both sender and userID are the same one that sent the message. Even if I hardcode it such as:
Both sender and userID will be whatever number the sender is (in my case 7)
Hope this helps solve it!
What else should I look for?
Thanks!
EDIT
A followup test shows that the:
Code: Select all
public void OnPrivateMessage(string message, User sender, int roomId, int userId)
{
Debug.Log("sender" + sender.GetId());
Debug.Log("userId" + userId);
}
Both sender and userID are the same one that sent the message. Even if I hardcode it such as:
Code: Select all
// Send the chat message to all other users
public void SendPrivateMsg(string message, int SFSUserID)
{
SmartFoxClient client = NetworkController.GetClient();
client.SendPrivateMessage(message, 0);
}
Both sender and userID will be whatever number the sender is (in my case 7)
Hope this helps solve it!
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
-
- Posts: 61
- Joined: 16 Jan 2009, 14:48
Same Issue
That fine.
But why is it still not showing the receiver id?
But why is it still not showing the receiver id?
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 16 guests