File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,45 @@ private val connection: HubConnection = WebSocketHubConnection("http(https)://hu
2929```
3030Thread(Runnable {
3131 try {
32- connection.connect("Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Ijc5NzhjMjI3LWViMGItNGMwOS1iYWEyLTEwYmE0MjI4YWE4OSIsImNlcnRzZXJpYWxudW1iZXIiOiJtYWNfYWRkcmVzc19vZl9waG9uZSIsInNlY3VyaXR5U3RhbXAiOiJlMTAxOWNiYy1jMjM2LTQ0ZTEtYjdjYy0zNjMxYTYxYzMxYmIiLCJuYmYiOjE1MDYyODQ4NzMsImV4cCI6NDY2MTk1ODQ3MywiaWF0IjoxNTA2Mjg0ODczLCJpc3MiOiJCbGVuZCIsImF1ZCI6IkJsZW5kIn0.QUh241IB7g3axLcfmKR2899Kt1xrTInwT6BBszf6aP4 ")
32+ connection.connect("Bearer your_token ")
3333 } catch (ex: Exception) {
3434 runOnUiThread { Toast.makeText(this@MainActivity, ex.message, Toast.LENGTH_SHORT).show() }
3535 }
3636 connection.addListener(this@MainActivity)
3737 connection.subscribeToEvent("Send", this)
3838 }).start()
39+ ```
40+
41+ Invoke method
42+
43+ ```
44+ btnHello.setOnClickListener {
45+ connection.invoke("Send", "Hello")
46+ }
47+ ```
48+
49+ #### Java example
50+
51+ ```
52+ final HubConnection connection = new WebSocketHubConnection("http://192.168.0.104:5002/signalr/hubs/auth");
53+ ```
54+
55+ ```
56+ new Thread(new Runnable() {
57+ @Override
58+ public void run() {
59+ connection.connect("Bearer your_token");
60+ }
61+ }).start();
62+ ```
63+
64+ Invoke method
65+
66+ ```
67+ btnHello.setOnClickListener(new View.OnClickListener() {
68+ @Override
69+ public void onClick(View v) {
70+ connection.invoke("Send", "Hello");
71+ }
72+ });
3973```
Original file line number Diff line number Diff line change 11// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
33buildscript {
4- ext. kotlin_version = ' 1.1.50 '
4+ ext. kotlin_version = ' 1.1.51 '
55 repositories {
66 google()
77 jcenter()
You can’t perform that action at this time.
0 commit comments