Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
Ambdós costats versió prèvia Revisió prèvia Següent revisió | Revisió prèvia | ||
android_threads [2024/10/21 13:39] enric_mieza_sanchez [Android i WebSockets] |
android_threads [2024/10/21 13:53] (actual) enric_mieza_sanchez [Android i WebSockets] |
||
---|---|---|---|
Línia 249: | Línia 249: | ||
- | Un cop fet tot això podrem emprar les biblioteques | + | Un cop fet tot això podrem emprar les biblioteques Java WebSockets al nostre codi: |
- | <code java> | + | < |
import org.java_websocket.client.WebSocketClient; | import org.java_websocket.client.WebSocketClient; | ||
import org.java_websocket.drafts.Draft_6455; | import org.java_websocket.drafts.Draft_6455; | ||
import org.java_websocket.handshake.ServerHandshake; | import org.java_websocket.handshake.ServerHandshake; | ||
+ | |||
+ | ... | ||
+ | |||
+ | WebSocketClient client = null; | ||
+ | URI location = " | ||
+ | |||
+ | try { | ||
+ | client = new WebSocketClient(new URI(location), | ||
+ | client.connect(); | ||
+ | } catch (URISyntaxException e) { | ||
+ | e.printStackTrace(); | ||
+ | System.out.println(" | ||
+ | } | ||
+ | | ||
+ | client.send(" | ||
... | ... | ||
</ | </ | ||
+ | <WRAP tip> | ||
+ | Teniu més explicacions i exemples a la pàgina [[WebSockets Java]] d' | ||
+ | </ | ||