LoadConfig and WebPlayer

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

Moderators: Lapo, Bax

Post Reply
Twelve47
Posts: 7
Joined: 16 Jun 2011, 13:20

LoadConfig and WebPlayer

Post by Twelve47 »

I'm running SFS2X RC2 with a Unity 3.3 project.

If I run my project in the editor or build as a standalone app everything works as expected.

If I build and run as a Web Player project, it fails to to load the sfs-config.

This is what I see in the Player Log.

Code: Select all

[SFS DEBUG] Failed to load config: Error loading config file: Attempt to access a private/protected method failed.
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
gui_Login:OnDebugMessage(BaseEvent)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.Logging.Logger:DispatchEvent(LoggerEvent)
Sfs2X.Logging.Logger:Log(LogLevel, String)
Sfs2X.Logging.Logger:Error(String[])
Sfs2X.SmartFox:OnConfigLoadFailure(BaseEvent)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.Util.ConfigLoader:OnConfigLoadFailure(String)
Sfs2X.Util.ConfigLoader:LoadConfig(String)
Sfs2X.SmartFox:LoadConfig(String, Boolean)
Sfs2X.SmartFox:LoadConfig()
The .html, .unity3d and sfs-config.xml files are all in the same directory.

Any ideas?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

Yeah - webplayers are not allowed to load files from the harddrive. I would remove config file usage and set the values in your code and/or inspector

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Twelve47
Posts: 7
Joined: 16 Jun 2011, 13:20

Post by Twelve47 »

Thanks Thomas

How would I go about setting the BlueBox config in code?

If I try setting smartFox.Config.HttpPort, I get a null exception, because config hasn't been set yet.

And if I can't set smartFox.Config to a new ConfigData, because Config is a read only property.
Twelve47
Posts: 7
Joined: 16 Jun 2011, 13:20

Post by Twelve47 »

(Bump)

If isn't possible to set the HttpPort in code, would it be possible to get a copy of the source code for the SmartFox2 Unity plugin so I could do a customised build with my server details?
GRIM2594
Posts: 52
Joined: 07 Nov 2010, 23:16

Post by GRIM2594 »

Twelve47 wrote:Thanks Thomas

How would I go about setting the BlueBox config in code?

If I try setting smartFox.Config.HttpPort, I get a null exception, because config hasn't been set yet.

And if I can't set smartFox.Config to a new ConfigData, because Config is a read only property.
If you are simply trying to connect your webplayer to a server, you can do this:

(This isn't a full use-as is code snippet, just an example)

Code: Select all

private string serverName = "00.000.00.000"; // IP address connecting to
private int serverPort = 9933; // the port
void Start()
{
     smartFox.Connect(serverName, serverPort);
}
Twelve47
Posts: 7
Joined: 16 Jun 2011, 13:20

Post by Twelve47 »

That only configures the connection for the socket connection.

Some of our users can only connect via a http proxy on port 80. (The've got a super strict IT policy which is beyond my control). I can set up jetty to use port 80 instead of the default. But now I need to configure my unity project so that if it can't establish a socket connection to host:9933 that it should try to use bluebox at host:80 instead.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

Hmmm - my bad. Misreading some of these things going fast over all forum posts.

I didnt immidiately get that the variables are unexposed to the client. Sorry.

I'll add it to the todo list to expose these things to the client

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Twelve47
Posts: 7
Joined: 16 Jun 2011, 13:20

Post by Twelve47 »

Hi Thomas,

Thanks, that helps.

I've been playing with this locally in the mean time.

The BlueBox code uses System.Net.WebClient which in turn uses HttpWebRequest, HttpWebRequest isn't supported in the Web Player Environment anyway. So I don't think BlueBox will ever work in Unity Web Player without a major re working to use the WWW class (if that is even suitable).
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Post by ThomasLund »

*sigh*

"Security" - meh.

I'll put on the list to recode the BB stuff to use sockets and raw http. That might help all issues.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Post Reply