Other WIKI pages:

Basic usage

The idea is very simple; you create a Fop2Client, add some event listeners, connect and authenticate and you're done.

var client = new Fop2Client();

//When connected OK try to authenticate
client.ConnectionStateChanged += (s, e) =>
    if (e.ConnectionState == ConnectionState.Connected)
        client.Authenticate("mycontext", "101", "mysecret");
        Console.WriteLine("Connection failed");

//When we have an authenticationresult, show a message
client.AuthenticationResultReceived += (s, e) =>
    if (e.Result == AuthenticationStatus.Success)
        Console.WriteLine("Login OK!");
        Console.WriteLine("Login failed!");

//Show messages as they are received
client.MessageReceived += (s, e) =>
    Console.WriteLine("Received: {0}", e.Message.Data);

//Let's kick everything into action!
The Fop2Client is a very low-level client; it allows you to directly control (within the Fop2 "protocol") the data being sent and handle the data being received as you please.

The "Fat" client

The Fop2FatClient extends the "normal" Fop2Client providing methods like Dial(), PickupRinging(), Record() etc. handling the internal details of each of these commands (the "fat" client, however, needs a lot of work). Both the normal and the "fat" client have extensive overloads and helper methods to make life easier. For example, there is a Send(string message) method that puts the 'raw' message on the wire and a Send(params string[] args) overload that handles concatenating all arguments:

client.Send("1|dial|00123456789|" + client.CurrentHash);
//equal to:
client.Send("1", "dial", "00123456789", client.CurrentHash);
//equal to:
The "CurrentHash" property exposes the currently active hash that was acquired during authentication; this is required to be sent along to the server on some actions. Both clients (normal and "fat") keep track of this type of information; the idea is that the "fat" client only provides extra helper methods that keep the details away.

Currently we have chosen to extend the Fop2Client with a Fop2FatClient. Since there's a lot to be done, we might decide in the future to "wrap" the normal client in a "fat" client to hide some of the "normal" client's 'dirty' internal implementation details too. Also, the naming of "fat" client is likely to change to something like 'Fop2SmartClient' or similar; suggestions are welcome! We might even consider renaming the "normal" client to "Fop2BaseClient" and the "fat" client to "Fop2Client". Anything is possible at this time.

Messages sent and received

Messages sent to the server are just 'plain flat strings' (although the FatClient abstracts that away and even the Send(params string[] args) hides this a little. Messages received from the server always are of type Fop2Message. This class defines 4 properties: Button, Command, Data and Slot. These are the low-level properties received and parsed (and, where applicable, even deflated/base64-decoded etc. although we might have missed some messagetypes). The "fat" client will most likely be raising events that abstract these details away too such that a message like:

{ "btn": "1", "cmd": "foostatus", "data": "c3RhdHVzPW9rfGNvbG9yPXJlZHxiYXNlNjQ9c3Vja3M=", "slot": "" }
is raised as a FooStatus event (with corresponding FooStatusEventHandler, FooStatusEventArgs exposing the parsed properties from the base64-decoded data etc.).

A word on documentation

The sourcecode on the clientlib is very well documented (and let's keep it that way!); with the help of Sandcastle Help File Builder this can easily be turned into a .chm, html-website and other format for your conveinience.

Reminder of our goal

Alongside the clientlib a simple application, Fop2DD (FOP2 Desktop Dialer) is developed which serves as proof-of-concept and playground to test, and play with, the clientlib. This application, however, is not the main goal of this project. The main goal of this project is to implement and extend the currently provided clientlib into a full-fledged, everything implemented, complete FOP2 client library which can be used by other projects and people to base their FOP2 clients on. As time goes by and the client library matures, however, the Fop2DD application will surely follow.

Last edited May 10, 2013 at 2:04 PM by RobIII, version 6


No comments yet.