Skip to content

Commit

Permalink
0.14.0-alpha.9
Browse files Browse the repository at this point in the history
  • Loading branch information
doorbash committed Oct 6, 2020
1 parent 9b193cd commit cfd0b6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Implementation of Colyseus client using Kotlin

```groovy
dependencies {
implementation 'io.github.doorbash:colyseus-kotlin:0.14.0-alpha.8'
implementation 'io.github.doorbash:colyseus-kotlin:0.14.0-alpha.9'
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'com.novoda.bintray-release'
apply plugin: 'kotlin'

group 'io.github.doorbash'
version '0.14.0-alpha.8'
version '0.14.0-alpha.9'

repositories {
mavenCentral()
Expand All @@ -38,7 +38,7 @@ dependencies {
publish {
def groupProjectID = 'io.github.doorbash'
def artifactProjectID = 'colyseus-kotlin'
def publishVersionID = '0.14.0-alpha.8'
def publishVersionID = '0.14.0-alpha.9'
userOrg = 'doorbash'
repoName = 'io.github.doorbash'
groupId = groupProjectID
Expand Down
31 changes: 15 additions & 16 deletions src/main/java/io/colyseus/serializer/SchemaSerializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ import io.colyseus.serializer.schema.ReferenceTracker
import io.colyseus.serializer.schema.Schema
import io.colyseus.serializer.schema.types.SchemaReflection
import io.colyseus.serializer.schema.types.SchemaReflectionType
import io.colyseus.util.Lock
import io.colyseus.util.allFields

class SchemaSerializer<T : Schema>(val schema: Class<T>) {
var state: T = schema.getConstructor().newInstance() as T
var refs = ReferenceTracker()
val lock = Lock()
// val lock = Lock()

fun setState(data: ByteArray, offset: Int = 0) {
lock.withLock {
state.decode(data, Iterator(offset), refs)
}
// lock.withLock {
state.decode(data, Iterator(offset), refs)
// }
}

fun patch(data: ByteArray, offset: Int = 0) {
lock.withLock {
state.decode(data, Iterator(offset), refs)
}
// lock.withLock {
state.decode(data, Iterator(offset), refs)
// }
}

fun teardown() {
Expand All @@ -34,15 +33,15 @@ class SchemaSerializer<T : Schema>(val schema: Class<T>) {
}

fun handshake(bytes: ByteArray?, offset: Int = 0) {
lock.withLock {
val reflection = SchemaReflection()
reflection.decode(bytes!!, Iterator(offset))
Context.instance.clear()
initTypes(reflection, schema = schema as Class<Any>)
for (rt in reflection.types) {
Context.instance.setTypeId(rt?.type!!, rt.id)
}
// lock.withLock {
val reflection = SchemaReflection()
reflection.decode(bytes!!, Iterator(offset))
Context.instance.clear()
initTypes(reflection, schema = schema as Class<Any>)
for (rt in reflection.types) {
Context.instance.setTypeId(rt?.type!!, rt.id)
}
// }
}

private fun initTypes(reflection: SchemaReflection, index: Int = reflection.rootType, schema: Class<out Any>) {
Expand Down

0 comments on commit cfd0b6b

Please sign in to comment.