Registering SFSEvent in Unity API with Java

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

xMoMx
Posts: 36
Joined: 13 Jun 2009, 06:11

Registering SFSEvent in Unity API with Java

Postby xMoMx » 16 Jun 2009, 23:12

Simple Question, what's the syntax for regis/unregis event in Unity API with java?

SmartFoxClientAPI.SFSEvent.onConnection = OnConnection;

seems to be working while '+= and -=' give out error. So ...how do we unregister Event in Java?

Trying to keep everything under Java here. :)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 17 Jun 2009, 05:49

If you mean javascript - then sorry. I dont know how to do it in javascript if at all possible.

The API is definitely C# minded only, but *might* work in javascript too

/Thomas
xMoMx
Posts: 36
Joined: 13 Jun 2009, 06:11

Postby xMoMx » 18 Jun 2009, 00:54

Still can't figure this out. Anyone has any insight?
xMoMx
Posts: 36
Joined: 13 Jun 2009, 06:11

Postby xMoMx » 19 Jun 2009, 00:34

Right now we have to have a C# buffer that broadcast all messages to Java Scripts. It gets really complicate when you have to convert Variables back and forth between a bunch of functions.

Anyone? Lapo?

:cry:
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 19 Jun 2009, 05:52

I dont think I've ever have heard of anyone trying to use the API the way you try it.

Your problem isnt really API related though, but more JavaScript/UnityScript related. If I were you I would try the mono or the Unity forums to find an answer on how to register multiple delegates similar to the -= and += in C#

But in general I would maybe advice you to rethink the usage of JavaScript together with the API if you are doing a commercial game - its certainly not supported in this end, it is not tested and you are more or less on your own from help.

With that said Unity/mono compiles everything down to the same .NET binary soup. So theoretically its all the same once it has run through the compiler.

Sorry

/T
xMoMx
Posts: 36
Joined: 13 Jun 2009, 06:11

Postby xMoMx » 20 Jun 2009, 08:18

Oh man, I thought SFS people would prefer Java to C since most of your stuffs are written in it. It's a pain to write Client code in C then have to convert everything to JAVA for Server.

It would be a huge time saver... but I guess with the Java structure, this might not be possible. :oops:
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 20 Jun 2009, 08:47

Sorry man - but JavaSript/UnityScript has absolutely nothing to do with Java. Just to clear that part up. C# isnt like C at all either.

I actually code in C# because I am a Java developer, and C# is a lot more similar to Java than JavaScript/UnityScript is. You should really give it a shot if you like Java :-)

But really - I am sorry that I cant help here. You should not despair - again depending on what it is you are trying to do (commercial game vs. playing around on your own), you can still work with JavaScript/UnityScript in most of your game. You could write a thin C# network manager that you can access from your JavaScript/UnityScript game code, which handles all your delegates and callbacks - that way you have isolated the problem and do not have to port your entire game code to C#.

Just an idea

/Thomas
xMoMx
Posts: 36
Joined: 13 Jun 2009, 06:11

Postby xMoMx » 20 Jun 2009, 10:21

That's exactly what I did, having a C delegate script sending message to Java. Bit of a mess here, but I'll manage.

p.s. When I say C and Java, I mean C#/UnityScript. Converting UnityScript variables to Java is a lot easier. Just have to erase ":" in most case.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 1 guest