B4J Question WebSockets again, sorry

LucaMs

Expert
Licensed User
Longtime User
I was thinking only about the client version of my game, for the moment.

Now I wanted to try again your example "WebSocket Client Library" using an emulator.

Surprisingly, it now also works with the emulator.

But the biggest surprise is that the server can communicate simultaneously with more than one device (that server, only one ws).

I thought I had to create a WebSocket object for each player (I also hope that it is right to create a Player object with a member of type websocket).


I am writing this question while I "study" the code "WebSocket Client Library"
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I have not found any identifier for WebSocket objects.
But I have seen that it has an identifier for its Session objects.

Means this that I should (or I could) use a single WebSocket object and pass the Session object to my Player class?

Or should I use more WebSocket objects, otherwise the communication becomes onerous using one WS only?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Thanks, this is more understandable.

In this case, however, the object does not expose the collection of objects WS.

So, I could create a normal handler which creates and assign a new WS to each Player object.

All I want now is a "yes" or a "no", I do not want you to miss any more time, thank you.



[probably not: how could I "call" the normal handler and connetct with WS?

Perfect, I turn off the computer. I will turn it on in 2015 :D ]
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Each handler instance handles a single user. This is how the server architecture works.

You can access WebSockets of other users. See the Chat example. Specifically learn the code in ChatShared code module.


Yes, I am doing exactly that, I understand how Chat works (I had to interpret the JavaScript functions in the html files, but it was not hard) .

I will use a wshPlayer, a module called "GameManager" like the ChatShared and some normal classes clsRoom.
So, everything will be handled by the module.



TAE (I write so many times "Thanks Again Erel" that now I prefer to shorten :D)
 
Upvote 0
Top