UDP question
UDP question
Hi,
I have run the examples for SFS2X with no trouble. I am now trying to modify the UNITY3D Connector example to use the UDP channel.
I added a new UDP port, in addition, to the TCP port. The ports are both set to 9933. The smartfox.log reports back that both UDP and TCP were successfully created.
I reviewed your "GettingStarted with the UDP protocol" and tried to make a simple modification to the Unity3D Connector example.
I added an event listener,
smartfox.AddEventListener(SFSEvent.UDP_INIT, onUdpInit)
To the onConnection function, I added,
smartfox.InitUDP();
I created a new function called onUDPInit that is supposed to print "UDP Ready" when the UDP_Init event occurs.
However, I do not think that the UDP_INIT event is firing.
Also, Unity does not seem to complain when I add the smartfox.InitUDP(), so it appears to find the Smartfox2.dll.
I looked at the actionscript 3 API and found some info that does not appear in the Unity Api docs. I am not sure if I should assume they are the same.
Does Unity use UDP_INIT or something else?
What are the parameters that InitUDP(?,?,?) accepts, if any?
Should I be using the connection event for TCP to send the InitUDP()?
Thanks,
Steve
I have run the examples for SFS2X with no trouble. I am now trying to modify the UNITY3D Connector example to use the UDP channel.
I added a new UDP port, in addition, to the TCP port. The ports are both set to 9933. The smartfox.log reports back that both UDP and TCP were successfully created.
I reviewed your "GettingStarted with the UDP protocol" and tried to make a simple modification to the Unity3D Connector example.
I added an event listener,
smartfox.AddEventListener(SFSEvent.UDP_INIT, onUdpInit)
To the onConnection function, I added,
smartfox.InitUDP();
I created a new function called onUDPInit that is supposed to print "UDP Ready" when the UDP_Init event occurs.
However, I do not think that the UDP_INIT event is firing.
Also, Unity does not seem to complain when I add the smartfox.InitUDP(), so it appears to find the Smartfox2.dll.
I looked at the actionscript 3 API and found some info that does not appear in the Unity Api docs. I am not sure if I should assume they are the same.
Does Unity use UDP_INIT or something else?
What are the parameters that InitUDP(?,?,?) accepts, if any?
Should I be using the connection event for TCP to send the InitUDP()?
Thanks,
Steve
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Hey Steve,
The AS3 InitUDP takes various parameters to the InitUDP, but the Unity dll doesnt. This is due to UDP only being supported by the AS3 API in some cases (only in standalone flash - not web). In Unity dll we support it all the time and thus we dont need to specify which UDPmanager to use.
Back to your question. The event listener should definitely fire on response from the server (it does in my unit tests).
Any error messages? What does the console log say when you run loggin in e.g. info level?
/Thomas
The AS3 InitUDP takes various parameters to the InitUDP, but the Unity dll doesnt. This is due to UDP only being supported by the AS3 API in some cases (only in standalone flash - not web). In Unity dll we support it all the time and thus we dont need to specify which UDPmanager to use.
Back to your question. The event listener should definitely fire on response from the server (it does in my unit tests).
Any error messages? What does the console log say when you run loggin in e.g. info level?
/Thomas
My apologies for this, there's evidently an error with the docs.
The initialization of the UDP channel should be done after having logged in. This is because the server security system doesn't allow a generic connection (not User) to start a UDP session.
I am in the process of updating the docs. They will be up in a moment.
Sorry for the inconvenice
The initialization of the UDP channel should be done after having logged in. This is because the server security system doesn't allow a generic connection (not User) to start a UDP session.
I am in the process of updating the docs. They will be up in a moment.
Sorry for the inconvenice
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Hi Thomas,
Yes, it is now working
But.....I had to figure out one last thing.
The sfs-config.xml file example should use <SmartFoxConfig> instead of
<SmartFoxClient> in the C# LoadConfig method XML example (Unity API)
Maybe, it should also be clarified in the "Getting started with the UDP protocol" under "Client Side Configuration"?
I might not have the full story yet, let me know:)
Thanks for the help,
Steve
Yes, it is now working
But.....I had to figure out one last thing.
The sfs-config.xml file example should use <SmartFoxConfig> instead of
<SmartFoxClient> in the C# LoadConfig method XML example (Unity API)
Maybe, it should also be clarified in the "Getting started with the UDP protocol" under "Client Side Configuration"?
I might not have the full story yet, let me know:)
Thanks for the help,
Steve
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Hi,
I have been looking through the documentation and cannot figure out how to choose when the (Unity API) extension request is sent by UDP vs. TCP.
The Actionscript 3 API seems to allow for a boolean: useUDP, as well as, the server side com.smartfoxserver.v2.api.SFSAPI.
How would I send the following example, from your Unity API documentation, as UDP? Am I on the wrong track here?
The following example shows how to send a custom extension request
CopyC#
ISFSObject parameters = SFSObject.NewInstance();
smartFox.Send( new ExtensionRequest("MyExt", parameters) );
Thanks,
Steve
I have been looking through the documentation and cannot figure out how to choose when the (Unity API) extension request is sent by UDP vs. TCP.
The Actionscript 3 API seems to allow for a boolean: useUDP, as well as, the server side com.smartfoxserver.v2.api.SFSAPI.
How would I send the following example, from your Unity API documentation, as UDP? Am I on the wrong track here?
The following example shows how to send a custom extension request
CopyC#
ISFSObject parameters = SFSObject.NewInstance();
smartFox.Send( new ExtensionRequest("MyExt", parameters) );
Thanks,
Steve
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Hey Steve,
Basically you simply add a boolean true as the 4th parameter to the ExtensionRequest constructor:
And thats it!
If you dont want to specify the room parameter, then put in null. Thats the default.
So in your example:
/Thomas
Basically you simply add a boolean true as the 4th parameter to the ExtensionRequest constructor:
Code: Select all
public ExtensionRequest(string extCmd, ISFSObject parameters, Room room, bool useUDP)
And thats it!
If you dont want to specify the room parameter, then put in null. Thats the default.
So in your example:
Code: Select all
smartFox.Send( new ExtensionRequest("MyExt", parameters, null, true) );
/Thomas
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Hi,
I placed a config.xml file in the root of my Unity project folder to configure the application for using UDP. This seems to work in the editor, I'm still a bit concerned about this when it comes to uploading my application (and config.xml) to a server. I can't see how this is going to work. Basicly because when a user opens the page that embeds the application, his browser will fetch the .unity3d file and will run it on the users computer (that's why they need a unity player to see your application in the firstplace, right?). Then there's no way of the application being able to find the config.xml there. Could anyone confirm this?
Is there a way to compile the config file into the final application? Even though that would kind of beat the purpose of having the serperate config file in the first place, it would enable me to run my unity application with UDP.
Berry
I placed a config.xml file in the root of my Unity project folder to configure the application for using UDP. This seems to work in the editor, I'm still a bit concerned about this when it comes to uploading my application (and config.xml) to a server. I can't see how this is going to work. Basicly because when a user opens the page that embeds the application, his browser will fetch the .unity3d file and will run it on the users computer (that's why they need a unity player to see your application in the firstplace, right?). Then there's no way of the application being able to find the config.xml there. Could anyone confirm this?
Is there a way to compile the config file into the final application? Even though that would kind of beat the purpose of having the serperate config file in the first place, it would enable me to run my unity application with UDP.
Berry
Who is online
Users browsing this forum: No registered users and 63 guests