jWebSocket Forum

[Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Determining if client is web-based  XML
Forum Index » Server side Plug-Ins, Apps, Listeners and Filters
Author Message
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Hello,

In my plugin I would like to be able to determine if my client starting is from a browser or not. As there is support of Java client.

I go into debug in connectorStarted of my plugin but nothing help me to determine this. I also search a little in the javadoc but I was not able to find anything related to this.

How can I do it ?

Many thanks

++
Mickaël
vbarzana

jWebSocket Forum Fan
[Avatar]

Joined: 11/07/2011 09:13:42
Messages: 109
Offline

Hi Mickaël,
actually that shouldn´t be so complicated, take a look into my example:


Best Regards,
Victor
[WWW]
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Hi !

Thanks for your tips I'll try it asap and give you feedback.

++
Mickaël
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Hello,

I try your solution, in the method connectorStarted(..) of my plugin class I add the following code :

final Object clientType = aConnector.getVar("clientType");
final Object clientName = aConnector.getVar("clientName");
final Object clientVersion = aConnector.getVar("clientVersion");
final Object clientInfo = aConnector.getVar("clientInfo");
final Object jwsType = aConnector.getVar("jwsType");
final Object jwsVersion = aConnector.getVar("jwsVersion");
final Object jwsInfo = aConnector.getVar("jwsInfo");

LOGGER.debug("New Client infos : \n clientType " + clientType
+ "\n clientName " + clientName
+ "\n clientVersion " + clientVersion
+ "\n clientInfo " + clientInfo
+ "\n jwsType " + jwsType
+ "\n jwsVersion " + jwsVersion
+ "\n jwsInfo " + jwsInfo);


Unfortunalty, whatever the client type ( webbrowser, app) I got the same answear :

clientType null
clientName null
clientVersion null
clientInfo null
jwsType null
jwsVersion null
jwsInfo null




Should it be done later ?
vbarzana

jWebSocket Forum Fan
[Avatar]

Joined: 11/07/2011 09:13:42
Messages: 109
Offline

Hi again Mick,
Yes you are right, I am sorry, in the connector started still we don't know know which client is connected, but you can try for example, send any token to the server from the client or have a thread in the server side that extracts this data for every connector:


by the way, you could use as well the processToken menthod like this:

My best regards,
Victor
[WWW]
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Does it means that on any request the informations are filled/available ?

[Edit]
I try it with with the processToken way... and still the same! got "null"

is it something 'new'? I mean I'm not sure having the lastest version. ( I have a RC1 but maybe not the latest build)

This message was edited 1 time. Last update was at 14/11/2013 11:30:09

mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

it's a RC0

"jWebSocket Ver. 1.0 RC0 (build 30401) (32bit)"
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Ok... in fact your last method is working for a web browser I'm able to get a "clientType browser" when connection is performed via firefox for example.

If it's an app, I got nothing. Do I have to implement something on client side ?
vbarzana

jWebSocket Forum Fan
[Avatar]

Joined: 11/07/2011 09:13:42
Messages: 109
Offline

Hi again ,
Probably you will have to implement a solution in your side because If your client does not return anything, you will have to do it yourself, for example in your client you can wait for OnOpen event and then send a token to the system plugin with type "headers" and the same variables in the token, so the server will know your data. Anyway I will ask to Alex to see if that is implemented in all clients.
Regards, Victor
[WWW]
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Hi,

I actually go into jWebsocket javascript code and detect that you were sending the "header" request with details of variables.

I'm quite surprise this is not included into the java based class but I can do it in my side if this is the jwebsocket team request. I just not want to do it if you plan to do it quite soon. Just keep me in touch with your position on that particular subject.

Many Thanks for your support !
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

I did the changes as you suggested and it works. Please find below the code :






But I guess I've found a bug ! Note that I updated my libs to the latest version available for download ( "jWebSocket Ver. 1.0 RC1 (build 3051 (32bit)" )

Here is a quick "how to reproduce", with a simple java client which try to connect to a server.

1- launch the java client app
-> it tries to connects and we can see that we trigger the processClosed and processReconnecting methods

2- launch the server (I used the jWebSocketServerLocal.bat available with download)
-> once the server is ready, the processOpening and processOpened method are triggered
-> until there this is ok.

3 - shutdown the server
-> client trigger processClosed and processReconnecting methods (ok)

4 - relaunch the server
-> client connect but does not trigger the processOpening and processOpened method again. NOK


From my point of view processOpen.. should be triggered even if it's a REconnection

What do you think about that ?


kyberneees

jWebSocket Committer
[Avatar]

Joined: 10/10/2010 23:13:03
Messages: 96
Offline

Hi mick,
Sorry to get a bit late to this discussion.

As you may noticed due to Victor hints, we have a sentHeaders method on each client library that send to the server the information you require:


We tested your suggestion about to call all events "opening", "opened", "reconnecting" instead of "reconnecting" only. We agree with you that all events should be called.
However we could not reproduce the issue in our side, resulting that all is working as expected.

Can you tell me what jWebSocket version are you using?
Can you consider to update from svn: svn checkout http://jwebsocket.googlecode.com/svn/
Or wait for RC2 version coming soon.

Best Regards,
Rolando

Ing. Rolando Santamaría Masó
Email: rsantamaria@jwebsocket.org
Twitter: https://twitter.com/kyberneees
[WWW]
mick

jWebSocket Forum User
[Avatar]

Joined: 03/10/2012 07:30:54
Messages: 16
Location: France
Offline

Hi Rolando,

It's a long time I've been looking at the forum and never got any notification of your answear...

I do not remember the exact issue.

I'll try to refind it asap.

Thanks for your answear.
julia

jWebSocket Forum User

Joined: 14/03/2017 12:00:24
Messages: 1
Offline

We are one of driving Web based information accumulation specialist organization in UK. We give a web inquire about administrations in various zones at extremely moderate cost. We have bunches of customers in various nation. Our principle customers from US, Australia and UK.We give a Web based information accumulation benefits in taking after regions I specify underneath quickly ,

Essay Writing Service
alexbret

jWebSocket Forum User

Joined: 25/04/2017 12:30:50
Messages: 1
Location: United Kingdom
Offline

This is a great post regarding Java programming. Every developer should know about this programming language as it is one of the important language. IT students should prepare all their assigned assignments on time and if they required then they shouldn't be hesitant to consult with UK Assignment Writer for the college student as they know how to write assignments for college students.

Assignment Writing Service UK
[WWW]
 
Forum Index » Server side Plug-Ins, Apps, Listeners and Filters
Go to:   
Powered by JForum 2.1.9 © JForum Team