SmartFox.LoadConfig method working?

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

SmartFox.LoadConfig method working?

Postby Jake-GR » 07 Jan 2012, 03:00

maybe i am missing something, but im trying to load a config file in unity, and nothing i seem to try works.

i have even tried LoadConfig("C:/sfs-config.xml"); but the only event that ever gets fired is CONFIG_LOAD_FAILURE, and setting the LoadConfig bool to true will not attempt a connection. Also (Application.dataPath + "/sfs-config.xml")... and i am positive its in the right folder as ive put it in every folder (just to see)

this is the xml file im using (from the API Docs, but with the correct port)

Code: Select all

<SmartFoxConfig>
    <ip>127.0.0.1</ip>
    <port>9933</port>
    <zone>simpleChat</zone>
</SmartFoxConfig>
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 07 Jan 2012, 07:03

trying to load a config file in unity

In Unity or SFS ?
Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

Postby Jake-GR » 07 Jan 2012, 07:54

In Unity (C#), using the SFS2X (RC3) client API.
(Unity/C#) API Reference:
http://docs2x.smartfoxserver.com/api-docs/csharp-doc/html/d17900a7-0de8-2115-8e3c-516c346c17ab.htm

I have also tried with RC1 with no luck. I can Connect() manually so I know its not an issue of the API not being imported correctly into Unity.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 10 Jan 2012, 10:55

There are some extra fields required than the ones you list (and that the documentation lists. Fixed in SVN now, sorry)

It should print the required node error in the console, but here are the required nodes:

Code: Select all

            if (GetNodeText(configNode, "ip")==null) {
               Logging.Logger.Instance.Error("Required config node missing: ip");
            }
            if (GetNodeText(configNode, "port")==null) {
               Logging.Logger.Instance.Error("Required config node missing: port");
            }
            if (GetNodeText(configNode, "udpIp")==null) {
               Logging.Logger.Instance.Error("Required config node missing: udpIp");
            }
            if (GetNodeText(configNode, "udpPort")==null) {
               Logging.Logger.Instance.Error("Required config node missing: udpPort");
            }
            if (GetNodeText(configNode, "zone")==null) {
               Logging.Logger.Instance.Error("Required config node missing: zone");
            }


So try to add udpIp and udpPort to your xml and see if it doesnt load!

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

Postby Jake-GR » 10 Jan 2012, 20:19

@ThomasLund:
Yup that did the trick, needed to add <udpIp> and <udpPort> into the .xml and use this line for loading:

Code: Select all

sfs.LoadConfig(Application.dataPath + "/sfs-config.xml", true);

Thanks for the info, now time to structure it into my tutorial videos :)
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 11 Jan 2012, 00:06

Like Thomas mentioned, it will be changed in the next release.
whornak
Posts: 86
Joined: 22 Sep 2009, 11:05

Re: SmartFox.LoadConfig method working?

Postby whornak » 23 Feb 2012, 23:09

I have been having the same issue loading the sfs-config.xml file. I am using C# 2008 not containing any SWF's yet. I am trying to use SmartFox2.dll ver.0.9.4.0 to extract the available servers to provide a listing but am not able to load the config file..

Regardless of what I do, and the fact that I have the sfs-config.xml file in the bin and root of the website, I get nothing but SFSEvent.CONFIG_LOAD_FAILURE. There is no error message provided so there is no way for me to figure out what this thing is doing or what is going wrong without guessing.

I have tried every variation of the LoadConfig parameters as well as placing the config file in all the places I thought would work. Also passing the entire file path and again no success.
Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

Re: SmartFox.LoadConfig method working?

Postby Jake-GR » 24 Feb 2012, 05:42

It may be that you dont have all the entries correctly formatted in the sfs-config.xml file... however, if you are just trying with a web build, LoadConfig is not compatible... it will only works with standalone build.
whornak
Posts: 86
Joined: 22 Sep 2009, 11:05

Re: SmartFox.LoadConfig method working?

Postby whornak » 24 Feb 2012, 12:26

If I understand you correctly, I cannot access SFS with C# through a web interface. So if having the browser based requirement for the available server selection it will have to be done through an SWF? Are there any other options?

Thanks
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: SmartFox.LoadConfig method working?

Postby Bax » 24 Feb 2012, 16:59

On the web C# is used in server pages which can0t communicate with SmartFoxServer for their nature.
Paolo Bax
The SmartFoxServer Team
Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

Re: SmartFox.LoadConfig method working?

Postby Jake-GR » 24 Feb 2012, 18:40

No, you can use C# (with Unity) and build a WebPlayer that will connect to a SmartFox server... its loading the config file that can not be done.
(that is how I am using it, I am building a WebPlayer, but instead of using the config file, the information is "hard-coded"... and remember the config file is completely optional)
Sunpar
Posts: 3
Joined: 22 Mar 2012, 17:44

Re: SmartFox.LoadConfig method working?

Postby Sunpar » 28 Mar 2012, 20:23

All I can do is "smile" right now. I kept on going through the tutorials even though I couldn't get LoadConfig to work for me. I am new at this, so I thought I'd just keep on getting familiar with the commands. I really have to laugh at myself now, as I am at the end and I have commented out almost the entire script and nothing works now. I know I must be missing something fairly minor and of course, the config file was optional. Like I said, I wanted the practice and enjoy searching for the ideas of others to fix the code.

The application.dataPath was giving me trouble as well.

If you want to help me, that would be great. If not, thank you for your time in producing these videos. I will keep plugging along, taking out and putting back. I should at least be able to get it back to Logging In. <grin> I really need this for a project I'm doing with Unity3D 3.5 release. The other guys are scrambling for a way around it; a quick fix somewhere else until we can get this SFSX2 connect figured out. They are leaving me alone, but rest assured, if I manage to get the code fixed, there will be sushi for everyone!

Thanks again,
(please excuse the rambling)
Sunpar

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 27 guests