client send session 0x7fffffff

This commit is contained in:
云风
2012-08-10 19:20:58 +08:00
parent 85f353b679
commit 70271817a1
4 changed files with 8 additions and 5 deletions

View File

@@ -124,8 +124,8 @@ static void
_forward(struct skynet_context * ctx,struct gate *g, int uid, void * data, size_t len) { _forward(struct skynet_context * ctx,struct gate *g, int uid, void * data, size_t len) {
struct connection * agent = _id_to_agent(g,uid); struct connection * agent = _id_to_agent(g,uid);
if (agent->agent) { if (agent->agent) {
// todo: client package has not session , send 0 // todo: client package has not session , send 0x7fffffff
skynet_send(ctx, agent->client, agent->agent, 0, data, len, 0); skynet_send(ctx, agent->client, agent->agent, 0x7fffffff, data, len, 0);
} else { } else {
char * tmp = malloc(len + 32); char * tmp = malloc(len + 32);
int n = snprintf(tmp,len+32,"%d data ",uid); int n = snprintf(tmp,len+32,"%d data ",uid);

View File

@@ -88,6 +88,10 @@ skynet.tostring = assert(c.tostring)
skynet.unpack = assert(c.unpack) skynet.unpack = assert(c.unpack)
function skynet.call(addr, deseri , ...) function skynet.call(addr, deseri , ...)
if deseri == nil then
local session = c.send(addr, -1, ...)
return coroutine.yield("CALL", session)
end
local t = type(deseri) local t = type(deseri)
if t == "function" then if t == "function" then
local session = c.send(addr, -1, ...) local session = c.send(addr, -1, ...)

View File

@@ -3,8 +3,7 @@ local client = ...
local session_id = 0 local session_id = 0
skynet.filter(function (session, address , msg, sz) skynet.filter(function (session, address , msg, sz)
if address == client then if session == 0x7fffffff then
assert(session == 0)
print("client message",skynet.tostring(msg,sz)) print("client message",skynet.tostring(msg,sz))
-- It's client, there is no session -- It's client, there is no session
session_id = session_id + 1 session_id = session_id + 1

View File

@@ -95,7 +95,7 @@ skynet_context_new(const char * name, const char *param) {
int int
skynet_context_newsession(struct skynet_context *ctx) { skynet_context_newsession(struct skynet_context *ctx) {
int session = ++ctx->session_id; int session = ++ctx->session_id;
if (session < 0) { if (session >= 0x7fffffff) {
ctx->session_id = 1; ctx->session_id = 1;
return 1; return 1;
} }