If i send this from the server
send("add", resObj, sender);
How do i then get the resObj in unity?
Where does the object go to?
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
in the OnExtensionResponse handler :
Code: Select all
private void OnExtensionResponse(BaseEvent evt) {
try {
string cmd = (string)evt.Params["add"];
ISFSObject dt = (SFSObject)evt.Params["params"];
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Is there anything else I need to do?
this codes not being executed
public void OnExtensionResponse(BaseEvent evt) {
string cmd = (string)evt.Params["cmd"];
SFSObject dataObject = (SFSObject)evt.Params["params"];
Debug.Log(cmd);
}
I'm managing to send to the server and do a trace, so I know that much is working, but the debug statment for the returned values is not being triggered.
this codes not being executed
public void OnExtensionResponse(BaseEvent evt) {
string cmd = (string)evt.Params["cmd"];
SFSObject dataObject = (SFSObject)evt.Params["params"];
Debug.Log(cmd);
}
I'm managing to send to the server and do a trace, so I know that much is working, but the debug statment for the returned values is not being triggered.
Checklist:
Did you include
somewhere during init?
Did you include
Code: Select all
m_sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
somewhere during init?
Yeah sorry I had missed that.
Is there a way to send different events from the server to different functions?
Like one for "add" one for "subtract"? or do they all have to go to 1 function and use logic?
--
Also server side, is there a short hand way to do SEND to all users in room etc?
One more
Is there a list of all users in the room ready built in? if so how do i access it?
Is there a way to send different events from the server to different functions?
Like one for "add" one for "subtract"? or do they all have to go to 1 function and use logic?
--
Also server side, is there a short hand way to do SEND to all users in room etc?
One more
Is there a list of all users in the room ready built in? if so how do i access it?
You can do one of two things, either you can add multiple if/else blocks so like
Or you can do like my blog tutorial does and sets up a handler.
My personal preference is to use the handler so that I don't have a giant list of message types.
Code: Select all
public void OnExtensionResponse(BaseEvent evt) {
string cmd = (string)evt.Params["cmd"];
SFSObject dataObject = (SFSObject)evt.Params["params"];
if(cmd == "add")
{
// add
}
else if(cmd == "subtract")
{
//subtract
}
Debug.Log(cmd);
}
Or you can do like my blog tutorial does and sets up a handler.
Code: Select all
try
{
string cmd = (string)evt.Params["cmd"];
ISFSObject dt = (SFSObject)evt.Params["params"];
ExtensionHandler handler;
if (handlers.TryGetValue(cmd, out handler))
{
handler(dt);
}
else
{
Debug.LogError("Got unhandled cmd: " + cmd);
}
}
catch (Exception e)
{
Debug.Log("Exception handling response: " + e.Message + " >>> " + e.StackTrace);
}
My personal preference is to use the handler so that I don't have a giant list of message types.
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Who is online
Users browsing this forum: No registered users and 56 guests