package com.example.tolucagraphics import android.annotation.SuppressLint import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import com.google.gson.Gson import okhttp3.Response import okhttp3.WebSocket import okhttp3.WebSocketListener class MesaJugando : AppCompatActivity() { val single = Socket val gson = Gson() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_mesa_en_juego) //val intentJoin = intent.getStringExtra("join") //Log.d("TAG", "Join from Intent: $intentJoin") //single.listener = Listener2() single.conectarconWS() } fun mensajeRecibido(text : String){ Log.d("TAG", text) } inner class Listener2 : WebSocketListener(){ @SuppressLint("SetTextI18n") override fun onMessage(webSocket: WebSocket, text: String) { super.onMessage(webSocket, text) runOnUiThread { Log.d("TAG", "Undefined text -> $text") /*if (text.contains(KeysWebSocket.commandResponse,true) && text.contains(KeysWebSocket.commandGetRooms)){ }*/ mensajeRecibido(text) } } override fun onOpen(webSocket: WebSocket, response: Response) { super.onOpen(webSocket, response) Log.d("TAG", "established connection! Table Game!!! <3") } override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { super.onClosing(webSocket, code, reason) Log.d("TAG", "$code $reason") } } }