void
network_init (void)
{
  GGZMod *mod;
  GIOChannel *channel;
  int ret, ggzmodfd;

  if (!ggzmod_is_ggz_mode ())
    return;

  mod = ggzmod_new (GGZMOD_GAME);
  ggzmod_set_handler (mod, GGZMOD_EVENT_SERVER, handle_ggzmod_server);

  ret = ggzmod_connect (mod);
  if (ret != 0) {
    /* Error: GGZ core client error (e.g. faked GGZMODE env variable) */
    return;
  }

  ggzmodfd = ggzmod_get_fd (mod);
  channel = g_io_channel_unix_new (ggzmodfd);
  g_io_add_watch (channel, G_IO_IN, handle_ggzmod, mod);

  ggzcomm_set_notifier_callback (network_message_cb);
  ggzcomm_set_error_callback (network_error_cb);

  init_chat (mod);
  init_player_list (mod);

  ggz_network_mode = TRUE;

}
Exemple #2
0
/****************************************************************************
  Initializations for GGZ, including checks to see if we are being run from
  inside GGZ.
****************************************************************************/
void ggz_initialize(void)
{
#ifdef GGZ_CLIENT
  with_ggz = ggzmod_is_ggz_mode();

  if (with_ggz) {
    ggz_begin();
  }
#endif

  gui_ggz_embed_ensure_server();
}