- Home /
Get the SFSObject from parameter (Smartfox server)
I send a message with SFSObject to smartfox server server as following script
public void SendMessageToOther(SFSObject dataObj) {
Room room = smartFox.LastJoinedRoom;
smartFox.Send(new PublicMessageRequest(dataObj.GetUtfString("type").ToString()+":"+dataObj.GetFloat("PositionIdx").ToString(),dataObj));
}
And I use the following script to parse the data
void OnPublicMessage2(BaseEvent evt) {
try {
string message = (string)evt.Params["message"];
User sender = (User)evt.Params["sender"];
// We use lock here to ensure cross-thread safety on the messages collection
lock (messagesLocker) {
messages.Add(sender.Name + " said " + message);
}
ISFSObject dt = (SFSObject)evt.Params["params"];
//Debug.Log(dt.GetFloat("type").ToString());
chatScrollPosition.y = Mathf.Infinity;
Debug.Log("User " + sender.Name + " said: " + message);
if(!sender.IsItMe)
{ if(message.Split(':')[0]=="moveEyeball")
parentObject.SendMessage("EyeBallMove",message.Split(':')[1]);
if(message.Split(':')[0]=="movePage")
gameObject.SendMessage("MoveToPosition",message.Split(':')[1]);
}//MoveCameraToPositon
}
catch (Exception ex) {
Debug.Log("Exception handling public message: "+ex.Message+ex.StackTrace);
}
}
I can get the message string from the parameter but I can't get SFSObject from the parameter Does anyone know how to solve this problem?
What, specifically, are you seeing? What error message do you get? What line is the error occurring at?
Answer by Nevak · Sep 26, 2012 at 02:07 PM
I know this question is old but just in case someone ends up here like I did:
ISFSObject dt = (SFSObject)evt.Params["data"];
Found out by doing:
foreach (DictionaryEntry item in evt.Params)
{
Debug.Log("Key: " + item.Key.ToString() + " Value: " + item.Value.ToString());
}
Your answer
Follow this Question
Related Questions
Send and recieve variables to all clients using smartfox 0 Answers
How do I setup a persistent guard to disconnect from server on exit? 0 Answers
Need lot of help regarding starting with smartFox server or just any server .... 1 Answer
Smart Fox Server Lobby 3 Answers
SFS2X Client unusual disconnect cause Unity freeze 0 Answers