HOME ABOUT
A way to turn a HTTP client into a service provider

Using the AjaxSync C++ Connector Example

The AjaxSync Server installation described in Setup comes with the Sources of the Connector library and an example chat client. In order to compile them you go to the AjaxSync application directory (or if you have no separate application directory, go to the AjaxSync main directory). You will find two subdirectories named "Connector" and "ConnectorPThread". The "Connector" directory contains the library, while the "ConnectorPThread" contains the example program and the POSIX threads wrapper.

You can compile them with the following commands:

cd Connector
make all
cd ../ConnectorPThread
make all
cd ..

If the cURL library (libcurl) or its development package is not installed on your system, the compilation of the Connector library will fail with a message like "curl/curl.h not found". Install libcurl and its development package and repeat the compilation.

  • On Debian you type: apt-get install libcurl4-openssl-dev
  • On Fedora you type: yum install libcurl-devel
  • On openSUSE you call yast and install package libcurl-devel
  • On Ubuntu you type: apt-get install libcurl4-openssl-dev
  • On CentOS you type: yum install curl-devel

However, the connector library does not work on CentOS 5.5. The underlying libcurl 7.15.5 seems to have an error. The first cURL call will succeed (in AjaxSync that is the "init" call), but every following call will raise an error, either "could not resolve" or "URL using bad/illegal format". On the other tested Linux variants it works flawlessly.

As said before, CentOS would not be my first choice.

After being compiled, you can call that program directly, but that is a longer command:

LD_LIBRARY_PATH=Connector/dist/Debug/GNU-Linux-x86/ \
    ConnectorPThreads/dist/Debug/GNU-Linux-x86/connectorpthreads \
    http://localhost/ajaxsync/ user2 123

In order to install that program correctly, you should copy the connector library inside of one of your library directories and the executable inside of one of your bin directories, for example:

cp -dp Connector/dist/Debug/GNU-Linux-x86/libajaxsync.so \
    /usr/local/lib
cp -dp ConnectorPThreads/dist/Debug/GNU-Linux-x86/connectorpthreads \
    /usr/local/bin
ldconfig

Do not forget to call ldconfig, or the library still would not be found.

After that installation, you could call the application simply like this:

connectorpthreads http://localhost/ajaxsync/ user2 123

A call without parameters will explain the parameters. They are:

connectorpthreads <URL of AjaxSync Server with trailing slash> \
    <AjaxSync username> <associated password>

Be aware that you will get strange effects if you start the program and it has not write access to the local directory. There will be no crash and no error message, because it is not tested that the cookie jar could be created; but if it couldn't, your session will be broken from the start. So be aware if you start the program like said before in the AjaxSync application directory, then you have to have root access. Especially on Ubuntu that means you have to start the program with sudo.