Alternative to GWT in Ajax connection
Alternative to GWT in Ajax connection
Hello,
I am finding GWT unwieldy, not to mention some of its components don't work on some browsers (mobile safari).
Is there another way to connect to a chat room and send it commands through a non-flash based Ajax client ?
Can I compile in the GWT java library on the server side then connect to it through a non GWT object? Say straight xmlRequestObject or Jquery ? if so what is the protocol ? Is there an example ?
thanks.
I am finding GWT unwieldy, not to mention some of its components don't work on some browsers (mobile safari).
Is there another way to connect to a chat room and send it commands through a non-flash based Ajax client ?
Can I compile in the GWT java library on the server side then connect to it through a non GWT object? Say straight xmlRequestObject or Jquery ? if so what is the protocol ? Is there an example ?
thanks.
Re: Alternative to GWT in Ajax connection
Just to mention that you can use GWT together with any library you want. The examples that comes with the AJAX API are created using GWT for the communication with BlueBox and Yahoo UI for the user interface.jozero wrote:I am finding GWT unwieldy, not to mention some of its components don't work on some browsers (mobile safari).
Yes. BlueBox allows the client to connect to SmartFoxServer using HTTP. This means any client-side technology that can make HTTP requests can connect to BlueBox.jozero wrote: Is there another way to connect to a chat room and send it commands through a non-flash based Ajax client ?
I've create the AJAX API using GWT because Action Script 3 and Java have very similar syntax and this allows fast convention of the AS3 API.
You can use any other javascript library as well you can use XMLHttpRequest or ActiveXObject("Microsoft.XMLHTTP")(for IE 6 or 5).
I'm not sure if I understood this one correctly. The AJAX API doesn't use any server side classes. It's entirely client side. BlueBox itself doesn't use any GWT code so it's not related to GWT in any way.jozero wrote:Can I compile in the GWT java library on the server side then connect to it through a non GWT object? Say straight xmlRequestObject or Jquery ? if so what is the protocol ? Is there an example ?
Only the client-side API that I've wrote is created with GWT but that doesn't means that only GWT can be used.
In short - GWT is used to create a AJAX API but BlueBox is not related to GWT in any way so any other technology/library can be used to create a AJAX API.
p.s. Actually it's not exactly true that the AJAX API doesn't use any server side classes. There is one class BlueBoxProxy that extends HttpServlet but it's used only when your GWT application runs in hosted mode.
Thank you for the quick reply.
I can find two examples of connecting through AJAX, both in the sfs_ajax_api download. However both (sfsChat, whiteboard) use GWT which obfuscates the javascript heavily so I can't learn from it. For example even the form action command is blank, and the submit in the obfuscated javascript doesn't point anywhere, so I don't even get what its submitting to with the requestobject (is it just to 8080 ?).
I would *really* appreciate a simple example on how to connect to bluebox via ajax(not how to connect, but what to send), then how to send it a single chat command via javascript.
I cannot find the bluebox API that would give me direction as well. [ clicking http://www.smartfoxserver.com/products/ ... #resources doesnt go anywhere ]
if its sfsChat.nocache.js, is there a non obfuscated or a documented version so I know what to call ?
thanks.
I can find two examples of connecting through AJAX, both in the sfs_ajax_api download. However both (sfsChat, whiteboard) use GWT which obfuscates the javascript heavily so I can't learn from it. For example even the form action command is blank, and the submit in the obfuscated javascript doesn't point anywhere, so I don't even get what its submitting to with the requestobject (is it just to 8080 ?).
I would *really* appreciate a simple example on how to connect to bluebox via ajax(not how to connect, but what to send), then how to send it a single chat command via javascript.
I cannot find the bluebox API that would give me direction as well. [ clicking http://www.smartfoxserver.com/products/ ... #resources doesnt go anywhere ]
if its sfsChat.nocache.js, is there a non obfuscated or a documented version so I know what to call ?
thanks.
NOTE: in the follow GWT code means a code that is complied or will be by GWT and javascript code means code that is written in javascript - for example Yahoo UI.
You can compile the GWT into not so obfuscated javascript. But for me even this form is no too clear. That's why I'm no calling method directly. For the send method for example I call
where the proxy is javascript object where GWT code add biding to it's methods:
This is the approach I found most easier - to create proxy object that is called both from the GWT and the other javascript code. This proxy object is created using native javascript code so it's not modified by GWT in any way. The javascript code also add methods that GWT can call - for example when new public message is received so the javascript code can update the UI.
The bridge function is created from the javascript code - not from GWT
that allows the GWT code to execute command in the same scope as the javascript code.
You can compile the GWT into not so obfuscated javascript. But for me even this form is no too clear. That's why I'm no calling method directly. For the send method for example I call
Code: Select all
proxy.sendPublicMessage(msg, module);Code: Select all
private native void moduleReady()/*-{
var proxy = $doc.bridge('proxy');
..................................................................................................
proxy.sendPublicMessage = @client.sfsChat::sendPublicMessage(Ljava/lang/String;Lclient/sfsChat;);
................................................................................................
}-*/;
The bridge function is created from the javascript code - not from GWT
Code: Select all
document.bridge = function(cmd){return eval(cmd, this)};
Can you give an example without GWT ? Can I initialize the proxy object by including a smartfox bluebox JS file ?
Lets say I want to write some simple javascript that connects to bluebox.
First what JS library do I include ? Where is it ?
From looking at the sfsChat GWT example I can see this is important :
If I include a certain Javascript file, can I make the calls above and have it work without GWT ?
You stated in your initial reply that GWT was not required, but with the lack of documentation I don't see how to use it. Can you give a complete AJAX example without reference to GWT ?
thanks again.
Lets say I want to write some simple javascript that connects to bluebox.
First what JS library do I include ? Where is it ?
From looking at the sfsChat GWT example I can see this is important :
Code: Select all
proxy.onModuleReady = { // what goes here }
then this :
proxy.login(data.username, module);
// I can see module is 'client.sfsChat@1'
then :
proxy.sendPrivateMessage(privateUserId, data.privateMessage, module);
but all proxy is is this :
var proxy = {};
You stated in your initial reply that GWT was not required, but with the lack of documentation I don't see how to use it. Can you give a complete AJAX example without reference to GWT ?
Okay thats clear enough, but how about everything before? You need to login, choose a room.That's why I'm no calling method directly. For the send method for example I call proxy.sendPublicMessage(msg, module);
thanks again.
Okay I see GWT on the backend is required (disregard the previous post). Is the example you gave above how to create the proxy object generically with javascript ?
What you are suggesting is :
A] in GWT use 'private native void moduleReady()' you mentioned above
B] this then exposes the proxy object in Javascript, and commands like 'proxy.sendPublicMessage(msg, module);' in the JS is valid.
Where is the list of the rest of the commands ? Is there docs on the bluebox API ?
thanks.
What you are suggesting is :
A] in GWT use 'private native void moduleReady()' you mentioned above
B] this then exposes the proxy object in Javascript, and commands like 'proxy.sendPublicMessage(msg, module);' in the JS is valid.
Where is the list of the rest of the commands ? Is there docs on the bluebox API ?
thanks.
If you want to use the AJAX API that is GWT module - yes. In the current state of the code at least I don't know a way to bypass the GWT completely.jozero wrote:Okay I see GWT on the backend is required
But everybody can create another AJAX API that does not use GWT at all. So from this point of view GWT is not required. If want to send only a single message you can write your own code that connects to blue box. Everything you need to write is code that makes HTTP request to the BlueBox and reads the answer(actually even to send a single message you need more than one request - you have to login the user, to join room and so on). Also of course you have to know the protocol. The good start point to learn how the BlueBox works is to take a look at the AS2 or AS3 API.
No the code from above is from the examples. It shows that is possible to combine GWT with other js libraries. The AJAX API itself does not contain such code. This means that you have to write the code that communicates with the js library.jozero wrote: What you are suggesting is :
A] in GWT use 'private native void moduleReady()' you mentioned above
B] this then exposes the proxy object in Javascript, and commands like 'proxy.sendPublicMessage(msg, module);' in the JS is valid.
Where is the list of the rest of the commands ? Is there docs on the bluebox API ?
thanks.
Hello,
Thanks for the replies but I don't think I am making myself clear enough.....
Using the existing Actionscript 3 or 2 smartfox API is fine for JS reference, the documentation is clear and simple.
However both require including PACKAGES it.gotoandplay.smartfoxserver and it.gotoandplay.smartfoxserver.data.
Where is the equivalent JAVASCRIPT package I can include to make the same calls ??
There must be some library. Stuff like 'http://127.0.0.1:8080/sfsChat?getVariables' doesn't work.
I'll request again. Give me one example of a login and sending one chat message use a URL and no GWT, then from those example I can take it from there. Thats all I need, and all I've been asking for, ONE straightforward non-GWT example.
Thanks for the replies but I don't think I am making myself clear enough.....
Using the existing Actionscript 3 or 2 smartfox API is fine for JS reference, the documentation is clear and simple.
However both require including PACKAGES it.gotoandplay.smartfoxserver and it.gotoandplay.smartfoxserver.data.
Where is the equivalent JAVASCRIPT package I can include to make the same calls ??
There must be some library. Stuff like 'http://127.0.0.1:8080/sfsChat?getVariables' doesn't work.
I'll request again. Give me one example of a login and sending one chat message use a URL and no GWT, then from those example I can take it from there. Thats all I need, and all I've been asking for, ONE straightforward non-GWT example.
Yep .... an example please.Everything you need to write is code that makes HTTP request to the BlueBox and reads the answer(actually even to send a single message you need more than one request - you have to login the user, to join room and so on).
The AS3 API is good start point as reference. Many things from the AS3 are missing but the ones that are in the AJAX API are used almost the same way. In the readme file of the AJAX API are listed the differences. All package and class names are the same. GWT converts Java to JavaScript so the GWT module is Java code not JavaScript so there are only Java packages and classes. More about the GWT modules and how to use them you can found at the GWT doc page.jozero wrote:Hello,
Thanks for the replies but I don't think I am making myself clear enough.....
Using the existing Actionscript 3 or 2 smartfox API is fine for JS reference, the documentation is clear and simple.
However both require including PACKAGES it.gotoandplay.smartfoxserver and it.gotoandplay.smartfoxserver.data.
Where is the equivalent JAVASCRIPT package I can include to make the same calls ??
There must be some library. Stuff like 'http://127.0.0.1:8080/sfsChat?getVariables' doesn't work.
I also want to state something. The AJAX API is open source project created by developer that uses SmartFoxServer - me
You cannot use the URL to pass variables to BlueBox because BlueBox uses POST not GET.jozero wrote:I'll request again. Give me one example of a login and sending one chat message use a URL and no GWT, then from those example I can take it from there. Thats all I need, and all I've been asking for, ONE straightforward non-GWT example.
As I said the AJAX API is GWT module so I'm afraid but to use this API you need GWT. I'll double check these days for some workarounds but it's very likely only to confirm that.
Example how to make a HTTP request or example of the BlueBox protocol?jozero wrote:Yep .... an example please.Everything you need to write is code that makes HTTP request to the BlueBox and reads the answer(actually even to send a single message you need more than one request - you have to login the user, to join room and so on).
Any example of a post :Example how to make a HTTP request or example of the BlueBox protocol?
- the URL you would point to (is it 127.0.0.1:8080?)
- Sample Post data. For example the parameters and an example value of :
- login
- joining a room
- sending a message.
Essentially what are you sending and where ? However if this requires GWT then thats fine, never mind.
You once said :
But then said :but BlueBox is not related to GWT in any way so any other technology/library can be used to create a AJAX API
I find GWT to be an absolute disaster (my own opinion). It takes the worst of javascript and java and sticks them together, along with unncessarily large client side files. So if there is no simple POST AJAX connection to Bluebox then that is fine, I am not interested in a GWT solution.In the current state of the code at least I don't know a way to bypass the GWT completely
If there was a clean solution to BlueBox you could write an AJAX post in a few bytes of javascript, keeping it small and clean which is important on hand held clients.
Now I'll try to explain it better. BlueBox is server-side technology. So you can use any client-side technology. You can write a client side API in any language - javascript, java, action script, python, ruby, C# and so on.jozero wrote: You once said :
But then said :but BlueBox is not related to GWT in any way so any other technology/library can be used to create a AJAX API
In the current state of the code at least I don't know a way to bypass the GWT completely
Now on the other side there is "SmartFoxServer Ajax API"(refered in my posts as "The AJAX API" - the "the" here is important). This is the API created by me and it's not related with BlueBox in any special way - "SmartFoxServer Ajax API" talks the SFS and BlueBox protocol and thats all. The same way the HTTP server is not related with any of the browsers - as far the browser speak HTTP everything is ok. So "SmartFoxServer Ajax API" speaks the BlueBox and SFS protocol and thats why BlueBox "accepts" it - the same way it will accept any other client that "talks" the same protocol. "SmartFoxServer Ajax API" is translation of the part of the SmartFoxServer AS3 API into GWT module - in other words Java.
So as I say a client side API can be create in any language with any technology as far the client side API "talks" the BlueBox and SFS protocol.
Now about "In the current state of the code at least I don't know a way to bypass the GWT completely" - it's the current state of the "SmartFoxServer Ajax API" not the BlueBox. May be here "SmartFoxServer Ajax API" is misleading - this does not means that it's the only one possible and only GWT can be used. You can write your own using any language and technology you want. But the one I wrote( "SmartFoxServer Ajax API") for bad or good is GWT module written in Java. So if you want to use "SmartFoxServer Ajax API" I'm afraid that in the current state of the "SmartFoxServer Ajax API" code you can't bypass GWT. But you're not bound to use "SmartFoxServer Ajax API" as the only way to communicate with BlueBox so from this point of view - BlueBox is not related to GWT(or any other client side technology).
When I wrote the "SmartFoxServer Ajax API" I have in mind heavy AJAX application - like white boards and sharing utilities, games and so on. I didn't have in mind hand held clients.jozero wrote: I find GWT to be an absolute disaster (my own opinion). It takes the worst of javascript and java and sticks them together, along with unncessarily large client side files. So if there is no simple POST AJAX connection to Bluebox then that is fine, I am not interested in a GWT solution.
If there was a clean solution to BlueBox you could write an AJAX post in a few bytes of javascript, keeping it small and clean which is important on hand held clients.
NOTE: When I mean "you can write" this means technologically possible. But both SmartFoxServer and BlueBox are protected by the copyright law so about the question "is it legal to write" - you have to consult lawyer.