Hello everyone,
we have just added a new section in the documentation called the Java Extension CookBook. It is a collection of code examples for many different use cases diveded in different categories: login handling, room creation, room joining, json protocol, string protocol, request dispatching and a lot more.
There are currently over 30 recipes in the cookbook and we'll keep adding them with next updates.
Also we encourage anyone who has an interesting code recipe to post it here or send it to our email. We will be very pleased to grow the cookbook's recipe list with the your help.
Follow this link to consult the CookBook
You will also find it linked in the main documentation menu, chapter 6.x
{ NEW } The Java Extensions CookBook
AS3 and Server-Side extensions
I moved recently from AS2 to AS3 and am looking for examples, tutorials, etc, in server-side AS3 extensions, but I find none.....
am I right in assuming that from here onwards server-side extensions will always be JavaScript?
It IS true that they are VERY similar.
Thanks,
Mariana
am I right in assuming that from here onwards server-side extensions will always be JavaScript?
It IS true that they are VERY similar.
Thanks,
Mariana
I did a cut+paste on the login to DB recipe, but got quite a few errors! I'm pretty sure I included all the right classes. Moo_Login is my classname/filename
Code: Select all
Moo_Login.java:15: Moo_Login is not abstract and does not override abstract meth
od handleRequest(java.lang.String,java.lang.String[],it.gotoandplay.smartfoxserv
er.data.User,int) in it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
public class Moo_Login extends AbstractExtension
^
Moo_Login.java:24: cannot find symbol
symbol : variable getOwnerZone
location: class Moo_Login
currentZone = helper.getZone(this.getOwnerZone);
^
Moo_Login.java:39: cannot find symbol
symbol : variable ieo
location: class Moo_Login
String nick = ieo.getParam("nick");
^
Moo_Login.java:40: cannot find symbol
symbol : variable ieo
location: class Moo_Login
String pass = ieo.getParam("pass");
^
Moo_Login.java:43: cannot find symbol
symbol : variable ieo
location: class Moo_Login
SocketChannel chan = (SocketChannel)ieo.getObject("chan"
);
^
Moo_Login.java:53: canLogin(java.lang.String,java.lang.String,java.nio.channels.
SocketChannel,java.lang.String) in it.gotoandplay.smartfoxserver.extensions.Exte
nsionHelper cannot be applied to (java.lang.String,java.lang.String,java.nio.cha
nnels.SocketChannel,it.gotoandplay.smartfoxserver.data.Zone)
newUser = helper.canLogin(nick, pass, ch
an, currentZone);
^
Moo_Login.java:55: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("_cmd", "logOK");
^
Moo_Login.java:56: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("id", String.valueOf(newUser.get
UserId()));
^
Moo_Login.java:57: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("name", newUser.getName());
^
Moo_Login.java:67: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("_cmd", "logKO");
^
Moo_Login.java:68: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("err", le.getMessage());
^
Moo_Login.java:75: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("_cmd", "logKO");
^
Moo_Login.java:76: cannot find symbol
symbol : variable res
location: class Moo_Login
res.put("err", "Sorry, invalid credentials.");
^
Moo_Login.java:81: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.LinkedList
ll.add(chan);
^
Moo_Login.java:84: cannot find symbol
symbol : variable res
location: class Moo_Login
sendResponse(res, -1, null, ll);
^
Moo_Login.java:98: cannot find symbol
symbol : variable SmartFoxLib
location: class Moo_Login
name = SmartFoxLib.escapeQuotes(name);
^
Moo_Login.java:99: cannot find symbol
symbol : variable SmartFoxLib
location: class Moo_Login
pass = SmartFoxLib.escapeQuotes(pass);
^
Moo_Login.java:107: cannot find symbol
symbol : class ArrayList
location: class Moo_Login
ArrayList queryRes = dbManager.executeQuery(sql);
^
17 errors
1 warning
Make sure to have all necessary classes in the classpath when compiling, according to the SFS version in use.
Also using an IDE such as Eclipse or Netbeans will help quite a lot.
You can read about all these things and a lot more here:
http://www.smartfoxserver.com/docs/docP ... nsions.htm
Also using an IDE such as Eclipse or Netbeans will help quite a lot.
You can read about all these things and a lot more here:
http://www.smartfoxserver.com/docs/docP ... nsions.htm
joinRoom recipe 1 error
There's a parameter missing in the helper.joinRoom command. The syntax demands a 'current room' integer variable, but this is not included in the example.
No, it is very unlikely we will ever support it.
If you need an OOP language for your server side code use Java, you will exploit the full potential of the JVM, including threading, synchronization etc...
Java and AS3 are very similar (actually AS3 is very much "inspired" by Java) but Java outperforms it by orders of magnitude.
If you know your OOP concepts the jump from AS3 to Java is minimal.
Take a look here:
http://www.infoq.com/articles/actionscript-java
If you need an OOP language for your server side code use Java, you will exploit the full potential of the JVM, including threading, synchronization etc...
Java and AS3 are very similar (actually AS3 is very much "inspired" by Java) but Java outperforms it by orders of magnitude.
If you know your OOP concepts the jump from AS3 to Java is minimal.
Take a look here:
http://www.infoq.com/articles/actionscript-java
So if I want to develop my new extensions with java, which java I have to learn? I see books about java 2, java 6, java 7 and some more.
I am developing other projects objectoriented in php, so I just have to extend my knowledge in some topics in java (java syntax, development enviroment and more). That's why I will first take a look into a book in combination with the java extension examples.
I am developing other projects objectoriented in php, so I just have to extend my knowledge in some topics in java (java syntax, development enviroment and more). That's why I will first take a look into a book in combination with the java extension examples.
Thanks!
Learn Java 5.
In other words any book dealing with Java 5 or higher is great. Java 6 didn't add anything new to the language, while Java 7 is not out yet.
Btw, if you are familiar with OOP in PHP (like PHP 5) you will find yourself pretty much at home because PHP "inherited" a lot from the Java OOP style.
In other words any book dealing with Java 5 or higher is great. Java 6 didn't add anything new to the language, while Java 7 is not out yet.
Btw, if you are familiar with OOP in PHP (like PHP 5) you will find yourself pretty much at home because PHP "inherited" a lot from the Java OOP style.
-
- Posts: 2
- Joined: 19 Jul 2010, 17:46
Lapo wrote:Learn Java 5.
In other words any book dealing with Java 5 or higher is great. Java 6 didn't add anything new to the language, while Java 7 is not out yet.
Btw, if you are familiar with OOP in PHP (like PHP 5) you will find yourself pretty much at home because PHP "inherited" a lot from the Java OOP style.
Java appears to be very similar to C# also.
-
- Posts: 32
- Joined: 19 Aug 2010, 22:44
- Location: Santa Monica
- Contact:
To serve Man ... Its a cook book
I am posting hoping someone can help..
The cookbook recipes for uservariables does not work, nor is it casting correctly for HashMap.
for example.. declaring TYPE_NUMBER by itself throws and error.. and when corrected with UserVariables.TYPE_NUMBER throw an entirely different error.
there is a slew of errors .. is there any class examples that I can glean from ?
The cookbook recipes for uservariables does not work, nor is it casting correctly for HashMap.
for example.. declaring TYPE_NUMBER by itself throws and error.. and when corrected with UserVariables.TYPE_NUMBER throw an entirely different error.
there is a slew of errors .. is there any class examples that I can glean from ?
Abyssus abyssum invocat,Ad hominem Ad Libitur..Non Conserva me ab animam inferno...liberate tutame ex inferis
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 25 guests