8000 Add trivial example client · chakra-coder/rsocket-java@1b2eee3 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 1b2eee3

Browse files
authored
Add trivial example client
1 parent 64fea50 commit 1b2eee3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,36 @@ Frames can be printed out to help debugging. Set the logger `io.rsocket.FrameLog
5252
- Java 8 - heavy dependence on Java 8 functional APIs and java.time, also on Reactor
5353
- Android O - https://github.com/rsocket/rsocket-demo-android-java8
5454

55+
## Trivial Client
56+
57+
```
58+
package io.rsocket.transport.netty;
59+
60+
import io.rsocket.Payload;
61+
import io.rsocket.RSocket;
62+
import io.rsocket.RSocketFactory;
63+
import io.rsocket.transport.netty.client.WebsocketClientTransport;
64+
import io.rsocket.util.PayloadImpl;
65+
import reactor.core.publisher.Flux;
66+
67+
import java.net.URI;
68+
69+
public class ExampleClient {
70+
public static void main(String[] args) {
71+
WebsocketClientTransport ws = WebsocketClientTransport.create(URI.create("ws://rsocket-demo.herokuapp.com/ws"));
72+
RSocket client = RSocketFactory.connect().keepAlive().transport(ws).start().block();
73+
74+
try {
75+
Flux<Payload> s = client.requestStream(PayloadImpl.textPayload("peace"));
76+
77+
s.take(10).doOnNext(p -> System.out.println(p.getDataUtf8())).blockLast();
78+
} finally {
79+
client.close().block();
80+
}
81+
}
82+
}
83+
```
84+
5585
## Bugs and Feedback
5686

5787
For bugs, questions and discussions please use the [Github Issues](https://github.com/RSocket/reactivesocket-java/issues).

0 commit comments

Comments
 (0)
0