AddListeners not working in Unity

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

Moderators: Lapo, Bax

nventimiglia
Posts: 4
Joined: 21 Oct 2015, 00:42

AddListeners not working in Unity

Postby nventimiglia » 23 Oct 2015, 01:38

I am following the very easy to understand basic examples found in the asset store. My client plugin has been updated to 1.6.2 and the examples work fine. That said, my own code is not working and I am not sure why. I have a service class which wraps the SmartFox client. I can connect fine and I see feedback on my server console. That said, the client side connection handler is not being invoked.

Here is my client code :

State = SFServiceStates.Connecting;
#if !UNITY_WEBGL
_sfs = new SmartFox();
#else
_sfs = new SmartFox(UseWebSocket.WS);
#endif
// Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
_sfs.ThreadSafeMode = true;
_sfs.Debug = true;

_sfs.AddEventListener(SFSEvent.CONNECTION, HandleConnection);
// AddListeners();

var cfg = new ConfigData();
cfg.Host = ip;
cfg.Port = port;
cfg.Zone = _proxy.Zone; //"BasicExamples"
_sfs.Connect(cfg);



Here is my server readout

18:29:37,527 INFO [main] v2.SmartFoxServer - Boot sequence starts...
18:29:37,837 INFO [main] core.SFSEventManager - AnonymousService-1 initialized
18:29:37,855 INFO [main] impl.DefaultFileReplicator - Using "C:\Users\NVENTI~1\AppData\Local\Temp\vfs_cache" as temporary files store.
18:29:37,895 INFO [main] v2.SmartFoxServer - License loaded:

==========================================
LICENSE DETAILS
------------------------------------------
Type : Community Edition
Max users : 100
==========================================

18:29:37,896 INFO [main] managers.SFSBannedUserStorage - BanUserStorage initialized
18:29:37,903 INFO [main] managers.SFSBannedUserManager - BanUser data loaded: 0 records.
18:29:37,907 INFO [main] v2.SmartFoxServer - Protocol Type is: BINARY
18:29:37,909 INFO [main] config.DefaultConfigLoader - Loading: zones\BasicExamples.zone.xml
18:29:37,928 INFO [main] config.DefaultConfigLoader - Loading: zones\SpaceWar.zone.xml
18:29:37,950 INFO [main] managers.SFSZoneManager -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>> Zone: BasicExamples
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

18:29:37,973 INFO [main] managers.SFSRoomManager - Room created: { Zone: BasicExamples }, [ Room: The Lobby, Id: 0, Group: default, isGame: false ]
18:29:37,974 INFO [main] managers.SFSZoneManager -

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>> Zone: SpaceWar
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

18:29:37,979 INFO [main] managers.SFSRoomManager - Room created: { Zone: SpaceWar }, [ MMORoom: Sol, Id: 1, Group: default, AOI: (900, 750, 0) ]
18:29:38,026 INFO [main] managers.SFSRoomManager - Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 2, Group: default, isGame: false ]
18:29:38,032 INFO [main] core.AdminToolService - AdminTool Service started
18:29:38,117 INFO [SFSWorker:Sys:1] v2.SmartFoxServer - Listening Sockets: { 0.0.0.0:9933, (Tcp) } { 127.0.0.1:9933, (Udp) } { 127.0.0.1:8888 (WebSocket) }
18:29:38,119 INFO [SFSWorker:Sys:1] v2.SmartFoxServer -
_____ _____ _____ ___ __ __
| __| __| __| |_ | | |
|__ | __|__ | | _|- -|
|_____|__| |_____| |___|__|__|
_____ _____ _____ ____ __ __
| __ | __| _ | \| | |
| -| __| | | |_ _|
|__|__|_____|__|__|____/ |_|
[ 2.10.0 ]

18:29:38,131 INFO [SFSWorker:Sys:1] v2.SmartFoxServer - SmartFoxServer 2X (2.10.0) READY!
18:29:39,043 INFO [main] v3.SessionFilter - BlueBox-2X Service (3.0.2) READY.
18:30:20,086 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52241 } on Server port: 9933 <---> 52241
18:30:58,290 INFO [Scheduler1-thread-1] sessions.DefaultSessionManager - Session removed: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52241 }
18:32:13,956 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 2, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52482 } on Server port: 9933 <---> 52482
18:32:48,270 INFO [Scheduler1-thread-1] sessions.DefaultSessionManager - Session removed: { Id: 2, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52482 }
18:33:26,653 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 3, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52637 } on Server port: 9933 <---> 52637
18:33:58,205 INFO [Scheduler1-thread-1] sessions.DefaultSessionManager - Session removed: { Id: 3, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52637 }
18:34:22,165 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 4, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52757 } on Server port: 9933 <---> 52757
18:34:58,312 INFO [Scheduler1-thread-1] sessions.DefaultSessionManager - Session removed: { Id: 4, Type: DEFAULT, Logged: No, IP: 127.0.0.1:52757 }
nventimiglia
Posts: 4
Joined: 21 Oct 2015, 00:42

Re: AddListeners not working in Unity

Postby nventimiglia » 23 Oct 2015, 01:45

Solution was

_sfs.ThreadSafeMode = false;
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: AddListeners not working in Unity

Postby Lapo » 23 Oct 2015, 08:00

Yes, which is the default mode.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 11 guests