Skip to content

Commit 670ffbe

Browse files
committed
Readme update part 2, update kotlin plugin
1 parent 4f2f80b commit 670ffbe

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,45 @@ private val connection: HubConnection = WebSocketHubConnection("http(https)://hu
2929
```
3030
Thread(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
```

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.1.50'
4+
ext.kotlin_version = '1.1.51'
55
repositories {
66
google()
77
jcenter()

0 commit comments

Comments
 (0)