Sipgate.IO is an event dispatcher library for the sipgate.io API.
To build Sipgate.IO from source you will need an F# 3.0 compiler and .NET development environment. The
.sln files in the source directory should be understood by command line tools like Microsoft's msbuild or Mono's xbuild as well as IDEs such as MonoDevelop or VisualStudio.
Sipgate.IO relies on the simple
System.Net.HttpListener for HTTP transport of events and exposes a standard CLI event interface through
In the simplest use case you construct an HTTP listener and an event dispatcher and run a synchronous main loop to handle incoming events:
open System.Net open Sipgate.IO use listener = new HttpListener(IgnoreWriteExceptions = true) listener.Prefixes.Add("http://localhost:8080/") let dispatch = CallEventDispatcher() dispatch.CallEvent.Add(fun evt -> printfn "call %s" evt.CallId) listener.Start() dispatch.Run(listener)
If Sipgate.IO can identify the type of event, it will dispatch a subclass of
Sipgate.IO.CallEventArgs. For example you can react to all incoming new calls like this:
dispatch.CallEvent.Add(function | :? NewCallEventArgs as evt when evt.IsIncoming -> printfn "incoming call %s from %s to %s" evt.CallId evt.Source evt.Target | _ -> ())
To request events when a call is answered or hung up, use the
RequestEvents method of a
Sipgate.IO.NewCallEvent. To request some action in response to an event, set the
Action property of any