B4J Question WebSocket know what device have disconnected

Discussion in 'B4J Questions' started by Douglas Farias, Jan 28, 2015.

  1. Douglas Farias

    Douglas Farias Expert Licensed User

    Hi.
    i m using this
    http://www.b4x.com/android/forum/threads/websocket-client-library.40221/
    to make a game server to my real time game, for now when i connect to the server i send phone infos, like phone id, android id etc....

    i need to know if this websocket have a id info on the server, because i go make a routine check and if the user log out of the game i need remove this player from the map.

    but how to know what player (device) have disconnected?
    Have a way to put a log on this server example?

    for example, i connect now with my phone, the server make log conected user = 1
    now i connect with my table, the server make log connected user = 2

    now i disconect my phone , game server show disconected user = 1

    how can i make this logs? its possible?

    on the server sample show only disconnected
    Code:
    Private Sub WebSocket_Disconnected

        timer1.Enabled = 
    False
        
    Log("disconnected")
    End Sub
    dont show what device as disconected

    thx
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    See the code in PushB4A module in the server example. It tracks the connected devices.
     
  3. Douglas Farias

    Douglas Farias Expert Licensed User

    this http://www.b4x.com/android/forum/threads/jwebsocketclient-library.40985/ ??
    i take a look, and this save only the device id, this i m already make here.

    but the solution is only check with a timer if the device stay connected?

    i have talk with my friend, he is c# programmer and he say me

    "if u do with sockets then u have a dc/log out function already
    [29/01/2015 22:45:56] HateMe (◕ _ ◕): bc u need to clear the socket"

    on the websocket dont have a option to see connected ids?
    like 0 to infinity

    if i connect now (first player) log connected player = 0
    if another player connect show = connected player = 1

    etc...

    if one player disconnect or have connetion lost, show log disconnected = 0
    etc..

    what the simple way to catch the devices connected and when disconnected ?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Check PushB4A module in the server example. There is no timer there.
     
  5. Douglas Farias

    Douglas Farias Expert Licensed User

    i have made a check on gameserver with a timer to move the character, its working now thx
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice