Permalink
Browse files

...

  • Loading branch information...
1 parent 78fe4a7 commit 9e41a2e0798e69b0aacdda52a2dc353c0db0376e @leonlee committed Dec 20, 2012
View
2 modules/sys-auth/src/main/groovy/org/riderzen/ogs/auth/User.groovy
@@ -35,7 +35,7 @@ class User extends BaseModel {
Long lastNodeId
Long lastLoginOn
- static User register(EventHelper eh) {
+ static register(EventHelper eh) {
def param = eh.param
User user = new User()
View
6 platform/common/src/main/groovy/org/riderzen/ogs/common/BaseModel.groovy
@@ -52,7 +52,7 @@ class BaseModel {
afterValidate?.call()
eh.newProcess(1)
eh.eb.send(Address.platJdbc.val, this) { message ->
- eh.sendOK()
+ eh.sendOK(this)
}
}
}
@@ -65,4 +65,8 @@ class BaseModel {
}
true
}
+
+ def toJson() {
+
+ }
}
View
25 platform/common/src/main/groovy/org/riderzen/ogs/common/EventHelper.groovy
@@ -2,15 +2,12 @@ package org.riderzen.ogs.common
import org.vertx.groovy.core.Vertx
import org.vertx.groovy.core.eventbus.EventBus
-import org.vertx.groovy.core.eventbus.Message
import org.vertx.groovy.deploy.Container
import org.vertx.java.core.eventbus.Message
import org.vertx.java.core.json.JsonObject
import org.vertx.java.core.logging.Logger
-import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger
-import java.util.concurrent.atomic.AtomicLong
/**
* Event Helper
@@ -50,33 +47,33 @@ class EventHelper {
message?.body
}
- void sendOK(Message<JsonObject> message) {
- sendOK(message, null)
+ void sendOK() {
+ sendOK(null)
}
- void sendStatus(String status, Message<JsonObject> message) {
- sendStatus(status, message, null)
+ void sendStatus(String status) {
+ sendStatus(status, null)
}
- void sendStatus(String status, Message<JsonObject> message, JsonObject json) {
+ void sendStatus(String status, JsonObject json) {
if (counter.decrementAndGet()) return
-
+
if (json == null) {
json = new JsonObject()
}
json.putString("status", status)
message.reply(json)
}
- void sendOK(Message<JsonObject> message, JsonObject json) {
- sendStatus("ok", message, json)
+ void sendOK(JsonObject json) {
+ sendStatus("ok", json)
}
- void sendError(Message<JsonObject> message, String error) {
- sendError(message, error, null)
+ void sendError(String error) {
+ sendError(error, null)
}
- void sendError(Message<JsonObject> message, String error, Exception e) {
+ void sendError(String error, Exception e) {
logger.error(error, e)
JsonObject json = new JsonObject().putString("status", "error").putString("message", error)
message.reply(json)
View
10 platform/tcp-server/src/main/groovy/org/riderzen/ogs/tcp/TcpServer.groovy
@@ -1,7 +1,11 @@
package org.riderzen.ogs.tcp
+import org.msgpack.MessagePack
+import org.msgpack.packer.Packer
import org.vertx.java.busmods.BusModBase
import org.riderzen.ogs.common.Address
+import org.vertx.java.core.buffer.Buffer
+
/**
* User: Leon Lee <mail.lgq@gmail.com>
* Date: 12-12-7
@@ -23,7 +27,11 @@ class TcpServer extends BusModBase {
sock.dataHandler { buffer ->
logger.debug("received ${buffer.lenght} bytes of data")
eb.send(Address.appProtocol.val, buffer) { message ->
- sock << message
+ MessagePack msgpack = new MessagePack()
+ def stream = new ByteArrayOutputStream()
+ Packer packer = msgpack.createPacker(stream)
+ packer.write(message.body.toString().getBytes())
+ sock << new Buffer(stream.toByteArray())
}
}
sock.exceptionHandler { e ->

0 comments on commit 9e41a2e

Please sign in to comment.