Skip to content

Commit

Permalink
Upgrade examples and README to Kotlin 1.0.0 GA
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Mashkov committed Mar 16, 2016
1 parent 4f2db58 commit 739d064
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ clients with RxJava/RxKotlin
With this thing you can simply do like this

```kotlin
import com.squareup.okhttp.*
import kotlinx.websocket.*
import kotlinx.websocket.gson.*
import com.squareup.okhttp.*
import rx.*
import rx.lang.kotlin.*
import java.util.concurrent.TimeUnit
import java.util.concurrent.*

// class we use to keep location, send and serialize to json
data class GeoLocation(val lat: Double, val lon: Double)

// here is just dummy geoPositionObservable that produces random coordinates
val geoPositionObservable =
kotlin.sequence { GeoLocation(Math.random(), Math.random()) }.toObservable()
generateSequence { GeoLocation(Math.random(), Math.random()) }.toObservable()

// create web socket that will check location every 5 seconds and
// send it if location changed since last time
Expand All @@ -40,10 +39,9 @@ val geoPositionWebSocket = OkHttpClient().
Another example to receive events from server on Twitter stream:

```kotlin
import com.squareup.okhttp.*
import kotlinx.websocket.*
import kotlinx.websocket.gson.*
import com.squareup.okhttp.*
import rx.*
import rx.lang.kotlin.*

// class we use to keep tweet
Expand All @@ -62,5 +60,4 @@ val twitterWebSocket = OkHttpClient().
newWebSocket("ws://some-server:8080/ws").
withGsonConsumer(observer).
open()

```
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ repositories {
}

sourceSets {
examples
examples {
compileClasspath += sourceSets.main.runtimeClasspath
}
}

dependencies {
Expand Down
7 changes: 3 additions & 4 deletions src/examples/kotlin/geolocation.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package jetsocket.examples.geo

import com.squareup.okhttp.*
import kotlinx.websocket.*
import kotlinx.websocket.gson.*
import com.squareup.okhttp.*
import rx.*
import rx.lang.kotlin.*
import java.util.concurrent.TimeUnit
import java.util.concurrent.*

// class we use to keep location, send and serialize to json
data class GeoLocation(val lat: Double, val lon: Double)

// here is just dummy geoPositionObservable that produces random coordinates
val geoPositionObservable =
kotlin.sequence { GeoLocation(Math.random(), Math.random()) }.toObservable()
generateSequence { GeoLocation(Math.random(), Math.random()) }.toObservable()

// create web socket that will check location every 5 seconds and
// send it if location changed since last time
Expand Down
3 changes: 1 addition & 2 deletions src/examples/kotlin/twitter-stream.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package jetsocket.examples.twitter

import com.squareup.okhttp.*
import kotlinx.websocket.*
import kotlinx.websocket.gson.*
import com.squareup.okhttp.*
import rx.*
import rx.lang.kotlin.*

// class we use to keep tweet
Expand Down

0 comments on commit 739d064

Please sign in to comment.