+/* Connect callback called after connected to remote server. */
+
+static void
+silc_connected(SilcClient client, SilcClientConnection conn,
+ SilcClientConnectionStatus status,
+ SilcStatus error, const char *message,
+ void *context)
+{
+ MyBot mybot = client->application;
+
+ if (status == SILC_CLIENT_CONN_DISCONNECTED) {
+ SILC_LOG_DEBUG(("Disconnected %s", message ? message : ""));
+ silc_client_stop(client, silc_stopped, mybot);
+ return;
+ }
+
+ if (status != SILC_CLIENT_CONN_SUCCESS &&
+ status != SILC_CLIENT_CONN_SUCCESS_RESUME) {
+ SILC_LOG_DEBUG(("Error connecting to server %d", status));
+ silc_client_stop(client, silc_stopped, mybot);
+ return;
+ }
+
+ fprintf(stdout, "\nMyBot: Connected to server\n\n");
+
+ /* Now that we have connected to server, let's join a channel named
+ "mybot". */
+ silc_client_command_call(client, conn, "JOIN mybot");
+
+ /* Save the connection context */
+ mybot->conn = conn;
+}
+
+/* Running callback given to silc_client_init called to indicate that the
+ Client Library is running. After this Client API functions can be
+ called. */
+
+static void silc_running(SilcClient client, void *application)
+{
+ MyBot mybot = application;
+
+ SILC_LOG_DEBUG(("Client is running"));
+
+ /* Connect to server. The silc_connected callback will be called after
+ the connection is established or if an error occurs during connecting. */
+ silc_client_connect_to_server(mybot->client, NULL,
+ mybot->public_key, mybot->private_key,
+ "silc.silcnet.org", 706,
+ silc_connected, mybot);
+}
+
+/* Client stopped callback given to silc_client_stop. Called to indicate
+ that Client Library is stopped. */
+
+static void silc_stopped(SilcClient client, void *context)
+{
+ SILC_LOG_DEBUG(("Client stopped"));
+}
+