Пример #1
0
void
muc_join(XMPP_SERVER_REC *server, const char *data, gboolean automatic)
{
	MUC_REC *channel;
	char *chanline, *channame, *nick, *key;
	void *free_arg;

	g_return_if_fail(IS_XMPP_SERVER(server));
	g_return_if_fail(data != NULL);
	if (!server->connected)
		return;
	if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
	    &chanline, &key))
		return;
	nick = muc_extract_nick(chanline);
	channame = muc_extract_channel(chanline);
	if (muc_find(server, channame) == NULL) {
		channel = (MUC_REC *)muc_create(server,
		    channame, NULL, automatic, nick);
		channel->key = (key == NULL || *key == '\0') ?
		    NULL : g_strdup(key);
		send_join(channel);
	}
	g_free(nick);
	g_free(channame);
	cmd_params_free(free_arg);
}
Пример #2
0
//initialize connection to the server.
void connect_to_server(connection_info *connection, char* user_input_name ,char *address, char *port)
{

  while(true)
  {
    get_username(connection->username, user_input_name );

    //Create socket
    if ((connection->socket = socket(AF_INET, SOCK_STREAM , IPPROTO_TCP)) < 0)
    {
        perror("Could not create socket");
    }

    connection->address.sin_addr.s_addr = inet_addr(address);
    connection->address.sin_family = AF_INET;
    connection->address.sin_port = htons(atoi(port));

    //Connect to remote server
    if (connect(connection->socket, (struct sockaddr *)&connection->address , sizeof(connection->address)) < 0)
    {
        perror("Connect failed.");
        exit(1);
    }

    send_join(connection);
    
    // there is no ACK, so no need to check following part
    /*
     SBCP_message msg;
     ssize_t recv_val = recv(connection->socket, &msg, sizeof(SBCP_message), 0);
    if(recv_val < 0)
     {
        perror("recv failed");
       exit(1);

    }
    else if(recv_val == 0)
     {
       close(connection->socket);
       printf("also full", connection->username);
       exit(1);
     }
     */
    break;
  }


  puts("Connected to server.");
  puts("Type your messages.");
}
static int on_join_timer(struct thread *t)
{
  struct pim_upstream *up;

  zassert(t);
  up = THREAD_ARG(t);
  zassert(up);

  send_join(up);

  up->t_join_timer = 0;
  join_timer_start(up);

  return 0;
}
Пример #4
0
static void process_message(struct irc_message *msg)
{
	if (!joined && !strcmp("MODE", msg->command)) {
		send_join();
		return;
	} else if (!sent_nick && !strcmp("NOTICE", msg->command)) {
		send_nick();
		return;
	} else if (!strcmp("PING", msg->command)) {
		send_ping(msg->params);
		return;
	} else if (strcmp("PRIVMSG", msg->command)) {
		return;
	}

	process_priv_message(msg);
}
static void pim_upstream_switch(struct pim_upstream *up,
				enum pim_upstream_state new_state)
{
  enum pim_upstream_state old_state = up->join_state;

  zassert(old_state != new_state);
  
  up->join_state       = new_state;
  up->state_transition = pim_time_monotonic_sec();

  if (PIM_DEBUG_PIM_EVENTS) {
    char src_str[100];
    char grp_str[100];
    pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
    pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
    zlog_debug("%s: PIM_UPSTREAM_%s: (S,G)=(%s,%s)",
	       __PRETTY_FUNCTION__,
	       ((new_state == PIM_UPSTREAM_JOINED) ? "JOINED" : "NOTJOINED"),
	       src_str, grp_str);
  }

  pim_upstream_update_assert_tracking_desired(up);

  if (new_state == PIM_UPSTREAM_JOINED) {
    forward_on(up);
    send_join(up);
    join_timer_start(up);
  }
  else {
    forward_off(up);
    pim_joinprune_send(up->rpf.source_nexthop.interface,
		       up->rpf.rpf_addr,
		       up->source_addr,
		       up->group_addr,
		       0 /* prune */);
    zassert(up->t_join_timer);
    THREAD_OFF(up->t_join_timer);
  }

}
Пример #6
0
 void connect(bool first)
 {
     gu_trace(shift_to(S_JOINING));
     gu_trace(send_join(first));
 }