global group multicast

This commit is contained in:
云风
2012-08-30 23:31:33 +08:00
parent 161528e686
commit 1ee802c5c5
17 changed files with 285 additions and 40 deletions

View File

@@ -135,7 +135,7 @@ _forward(struct skynet_context * ctx,struct gate *g, int uid, void * data, size_
}
struct connection * agent = _id_to_agent(g,uid);
if (agent->agent) {
// todo: client package has not session , send 0x7fffffff
// client package has not session , send 0x7fffffff
skynet_send(ctx, agent->client, agent->agent, SESSION_CLIENT, data, len, 0);
} else if (g->watchdog) {
char * tmp = malloc(len + 32);
@@ -202,6 +202,7 @@ _cb(struct skynet_context * ctx, void * ud, int session, uint32_t source, const
}
// big-endian
uint16_t len = plen[0] << 8 | plen[1];
void * data = mread_pull(m, len);
if (data == NULL) {
if (mread_closed(m)) {

View File

@@ -276,7 +276,7 @@ mread_poll(struct mread_pool * self , int timeout) {
socklen_t len = sizeof(struct sockaddr_in);
int client_fd = accept(self->listen_fd , (struct sockaddr *)&remote_addr , &len);
if (client_fd >= 0) {
// printf("MREAD connect %s:%u (fd=%d)\n",inet_ntoa(remote_addr.sin_addr),ntohs(remote_addr.sin_port), client_fd);
// printf("MREAD(%p) connect %s:%u (fd=%d)\n",self, inet_ntoa(remote_addr.sin_addr),ntohs(remote_addr.sin_port), client_fd);
struct socket * s = _add_client(self, client_fd);
if (s) {
self->active = -1;
@@ -390,6 +390,14 @@ mread_pull(struct mread_pool * self , int size) {
for (;;) {
int bytes = recv(s->fd, buffer, rd, MSG_DONTWAIT);
if (bytes > 0) {
/*
printf("recv: [%d] ",s->fd);
int i;
for (i=0;i<bytes;i++) {
printf("%02x ",(uint8_t*)buffer[i]);
}
printf("\n");
*/
ringbuffer_resize(rb, blk , bytes);
if (bytes < sz) {
_link_node(rb, self->active, s , blk);