当前位置: 首页>>代码示例>>C++>>正文


C++ Proto_Client::session_lost_handler方法代码示例

本文整理汇总了C++中Proto_Client::session_lost_handler方法的典型用法代码示例。如果您正苦于以下问题:C++ Proto_Client::session_lost_handler方法的具体用法?C++ Proto_Client::session_lost_handler怎么用?C++ Proto_Client::session_lost_handler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Proto_Client的用法示例。


在下文中一共展示了Proto_Client::session_lost_handler方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

extern int
proto_client_move(Proto_Client_Handle ch, Player_Move direction)
{
  int rc = 1, offset = 0;
  Proto_Session *s;
  Proto_Client *c = ch;
  s = &(c->rpc_session);

  //printf("Sending move command to server...\n\n");


  marshall_mtonly(s, PROTO_MT_REQ_BASE_MOVE);
  player_marshall(s, ClientGameState.me);
  proto_session_body_marshall_int(s, direction);

  rc = proto_session_rpc(s);

  if (rc != 1)
  {
	  c->session_lost_handler(s);
	  return rc;
  }
  else
  {
	offset = proto_session_body_unmarshall_int(s, 0, &rc);
	player_unmarshall(s, offset, ClientGameState.me);
  }

  if (rc < 0) printf("player move Error!\n");
  // else if (rc == 0) printf("player move rejected by server!\n");
//  else printf("Player move successful.\n");
  return rc;

}
开发者ID:jak87,项目名称:FalconPunch,代码行数:34,代码来源:protocol_client.c

示例2: close

static void *
proto_client_event_dispatcher(void * arg)
{
  Proto_Client *c;
  Proto_Session *s;
  Proto_Msg_Types mt;
  Proto_MT_Handler hdlr;

  pthread_detach(pthread_self());

  /*NOT_IMPL;i*/

  c = arg; 
  s = &(c->event_session);

  for (;;) {
    if (proto_session_rcv_msg(s)==1) {
      mt = proto_session_hdr_unmarshall_type(s);
      if (mt > PROTO_MT_EVENT_BASE_RESERVED_FIRST && 
	  mt < PROTO_MT_EVENT_BASE_RESERVED_LAST) {
		hdlr = c->base_event_handlers[mt-PROTO_MT_EVENT_BASE_RESERVED_FIRST-1];
	/*NOT_IMPL;//ADD CODE*/
	if (hdlr(s)<0) goto leave;
      }
    } else {
      c->session_lost_handler(s);
	  /*NOT_IMPL;//ADD CODE*/
      goto leave;
    }
  }
 leave:
  close(s->fd);
  return NULL;
}
开发者ID:samirahmed,项目名称:bogosort,代码行数:34,代码来源:protocol_client.c

示例3: fprintf

static int
do_dump_rpc(Proto_Client_Handle ch, Proto_Msg_Types mt)
{
    int rc;
    Proto_Session *s;
    Proto_Client *c = ch;

    if (proto_debug())
       fprintf(stderr, "do_dump_rpc \n");

    s = &(c->rpc_session);
    marshall_mtonly(s, mt);
    rc = proto_session_rpc(s);

    if (rc == 1)
    {
        proto_session_body_unmarshall_int(s, 0, &rc);
    }
    else
    {
        c->session_lost_handler(s);
        close(s->fd);
    }
    return rc;
}
开发者ID:al3jandr0,项目名称:FE,代码行数:25,代码来源:protocol_client.c

示例4: malloc

static int
do_cinfo_rpc(Proto_Client_Handle ch, int x, int y, Proto_Msg_Types mt){
  int rc=0;
  Proto_Session *s;
  Proto_Client *c = ch;
  Proto_Msg_Hdr *hdr = malloc(sizeof(Proto_Msg_Hdr));

  s = &(c->rpc_session);  

  bzero(hdr, sizeof(Proto_Msg_Hdr));

  hdr->pstate.v0.raw=x;
  hdr->pstate.v1.raw=y;
  hdr->type = mt;

  proto_session_hdr_marshall(s,hdr);

  proto_dump_msghdr(&(s->shdr));

  rc = proto_session_rpc(s);
  
  if(rc==1){
    proto_session_hdr_unmarshall(s,&s->rhdr);
    proto_dump_msghdr(&(s->rhdr));
  }
  else 
    c->session_lost_handler(s);

  return rc;
}
开发者ID:bborucki,项目名称:RepoMen,代码行数:30,代码来源:protocol_client.c

示例5: bzero

static int
do_goodbye_rpc(Proto_Client_Handle ch, Player *p, Proto_Msg_Types mt){
  int rc=0;
  Proto_Session *s;
  Proto_Client *c = ch;
  Proto_Msg_Hdr hdr;

  s = &(c->rpc_session);  

  bzero(&hdr, sizeof(Proto_Msg_Hdr));

  hdr.type = mt;
  proto_session_hdr_marshall(s,&hdr);
  proto_session_body_marshall_player(s,p);

  rc = proto_session_rpc(s);

  if(rc==1){
    proto_session_hdr_unmarshall(s,&s->rhdr);
    //    proto_dump_msghdr(&(s->rhdr));
  }
  else 
    c->session_lost_handler(s);
  return rc;
}
开发者ID:bborucki,项目名称:RepoMen,代码行数:25,代码来源:protocol_client.c

示例6: sizeof

extern int
proto_client_cell_info(Proto_Client_Handle ch, int x, int y, int * buf) {
  int team, oc, rc;
  char cell_type;
  Proto_Session *s;
  Proto_Client *c = ch;

  s = &(c->rpc_session);
  marshall_mtonly(s, PROTO_MT_REQ_BASE_GET_CELL_INFO);
  proto_session_body_marshall_int(s, x);
  proto_session_body_marshall_int(s, y);
  rc = proto_session_rpc(s);

  if (rc == 1) {
    proto_session_body_unmarshall_char(s, 0, &cell_type);
    if(cell_type == 'i')
      return -1;
    proto_session_body_unmarshall_int(s, sizeof(char), &team);
    proto_session_body_unmarshall_int(s, sizeof(char) + sizeof(int), &oc);

    buf[0] = (int)cell_type;
    buf[1] = team;
    buf[2] = oc;
  }

  else
    c->session_lost_handler(s);

  return rc;
}
开发者ID:jak87,项目名称:FalconPunch,代码行数:30,代码来源:protocol_client.c

示例7: close

// all rpc's are assume to only reply only with a return code in the body
// eg.  like the null_mes
static int
do_generic_dummy_rpc(Proto_Client_Handle ch, Proto_Msg_Types mt)
{
    int rc;
    Proto_Session *s;
    Proto_Client *c = ch;

    s = &(c->rpc_session);
    // marshall

    marshall_mtonly(s, mt);
    rc = proto_session_rpc(s);

    if (rc == 1)
    {
        proto_session_body_unmarshall_int(s, 0, &rc);
    }
    else
    {
        c->session_lost_handler(s);
        close(s->fd);
    }

    return rc;
}
开发者ID:al3jandr0,项目名称:FE,代码行数:27,代码来源:protocol_client.c

示例8: bzero

static int
do_cinfo_rpc(Proto_Client_Handle ch, Proto_Msg_Types mt, int x, int y)
{
    int rc;
    char cell, team, occupied;
    Proto_Session *s;
    Proto_Client *c = ch;
    Proto_Msg_Hdr h;

    s = &(c->rpc_session);
    bzero(&h, sizeof(h));
    h.type = mt;
    proto_session_hdr_marshall(s, &h);

    if (proto_debug())
       fprintf(stderr, "do_cinfo_rpc: cinfo(%d, %d) \n", x, y);

    if (proto_session_body_marshall_int(s, x) < 0)
        fprintf(stderr,
                "do_cinfo_rpc: proto_session_body_marshall_char failed. "
                "Not enough available sbufer space\n");

    if (proto_session_body_marshall_int(s, y) < 0)
        fprintf(stderr,
                "do_cinfo_rpc: proto_session_body_marshall_char failed. "
                "Not enough available sbufer space\n");

    rc = proto_session_rpc(s);
    if (rc == 1) {
        // unmarshall
        if (proto_session_body_unmarshall_char(s, 0, &cell) < 0)
             fprintf(stderr, "do_cinfo_rpc: proto_session_body_unmarshall_bytes failed\n");
        if (proto_session_body_unmarshall_char(s, 1, &team) < 0)
             fprintf(stderr, "do_cinfo_rpc: proto_session_body_unmarshall_bytes failed\n");
        if (proto_session_body_unmarshall_char(s, 2, &occupied) < 0)
             fprintf(stderr, "do_cinfo_rpc: proto_session_body_unmarshall_bytes failed\n");

        if (proto_debug())
             fprintf(stderr, "do_cinfo_rpc: unmarshalled response cell = %X, %c \n", cell & 0xFF, cell);
        if (proto_debug())
             fprintf(stderr, "do_cinfo_rpc: unmarshalled response team = %X, %c \n", team & 0xFF, team);
        if (proto_debug())
             fprintf(stderr, "do_cinfo_rpc: unmarshalled response occupied = %X, %c \n", occupied & 0xFF, occupied);

        rc = 0;
        rc =((cell & 0xFF)<<8) | ((team & 0xFF)<<16) | ((occupied & 0xFF)<<24);

        if (proto_debug())
           fprintf(stderr, "do_cinfo_rpc: return value = %X \n", rc);
    }
    else {
        c->session_lost_handler(s);
        close(s->fd);
    }
    return rc;
}
开发者ID:al3jandr0,项目名称:FE,代码行数:56,代码来源:protocol_client.c

示例9: printf

extern int
proto_client_hello(Proto_Client_Handle ch)
{
  int i = 0, rc = 1, offset = 0;
  Proto_Session *s;
  Proto_Client *c = ch;
  s = &(c->rpc_session);

  printf("Loading...\n\n");

  marshall_mtonly(s, PROTO_MT_REQ_BASE_HELLO);
  proto_session_body_marshall_int(s,i);
 
  rc = proto_session_rpc(s);
  
  if (rc == 1) 
    maze_unmarshall_row(s, offset, i);
  else
    c->session_lost_handler(s);
  
  if (Board.size / 20 > 0) {
    for (i = 1; i < Board.size / 20; i++) {
  
      proto_session_reset_send(s);
      marshall_mtonly(s, PROTO_MT_REQ_BASE_HELLO);
      proto_session_body_marshall_int(s,i);
      rc = proto_session_rpc(s);
      
      if (rc == 1)
	  maze_unmarshall_row(s, 0, i);
      else
	  c->session_lost_handler(s);
    }
  }
  //dump(); 

  return i;
}
开发者ID:jak87,项目名称:FalconPunch,代码行数:38,代码来源:protocol_client.c

示例10: memset

extern int
proto_client_new_player(Proto_Client_Handle ch, int * id)
{
  int rc = 1, offset = 0;
  Proto_Session *s;
  Proto_Client *c = ch;
  Player clientPlayer;
  memset(&clientPlayer, '\0', sizeof(clientPlayer));
  s = &(c->rpc_session);

  //printf("Requesting to create a new player...\n\n");

  marshall_mtonly(s, PROTO_MT_REQ_BASE_NEW_PLAYER);

  rc = proto_session_rpc(s);
  
  if (rc != 1)
  {
	  printf("new player rpc returned -1\n");
	  c->session_lost_handler(s);
	  return rc;
  }
  else 
  {

    rc = player_unmarshall(s,0, &clientPlayer);
    *id = clientPlayer.fd;
   
    // put the client player in it's proper place based on team and id.
    player_copy(&(ClientGameState.players[clientPlayer.team][clientPlayer.id]),&clientPlayer);
    
    //player_dump(&(ClientGameState.players[clientPlayer.team][clientPlayer.id]));
    // set the ClientGameState.me pointer to this address. This is where our player will
    // be unmarshalled from now on, with every update from the server.
    ClientGameState.me = &(ClientGameState.players[clientPlayer.team][clientPlayer.id]);
    
    //player_dump(ClientGameState.me);
  }

  //printf("new player id = %d, team = %d\n",p->id,p->team);

  if (rc < 0) printf("Player_unmarshall Error!\n");
  return rc;

}
开发者ID:jak87,项目名称:FalconPunch,代码行数:45,代码来源:protocol_client.c

示例11:

static int
do_generic_dummy_rpc(Proto_Client_Handle ch, Proto_Msg_Types mt){
  int rc;
  Proto_Session *s;
  Proto_Client *c = ch;

  s = &(c->rpc_session);  

  marshall_mtonly(s, mt);

  rc = proto_session_rpc(s);

  if (rc==1) {
    if(mt == PROTO_MT_REQ_BASE_HELLO){
      proto_session_hdr_unmarshall(s,&s->rhdr);
    } else
      proto_session_body_unmarshall_int(s, 0, &rc);
  } else {
    c->session_lost_handler(s);
  }

  return rc;
}
开发者ID:bborucki,项目名称:RepoMen,代码行数:23,代码来源:protocol_client.c


注:本文中的Proto_Client::session_lost_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。