private JObject AddListener(
string address,
int port,
int localAccepts,
int globalAccepts,
bool localAuthorizationRequired=false,
bool globalAuthorizationRequired=true)
{
IPAddress addr;
OutputListener listener;
IPEndPoint endpoint;
if (address==null) {
endpoint = new IPEndPoint(IPAddress.Any, port);
}
else if (IPAddress.TryParse(address, out addr)) {
endpoint = new IPEndPoint(addr, port);
}
else {
throw new RPCError(RPCErrorCode.InvalidParams, "Invalid ip address");
}
listener = PeerCast.StartListen(endpoint, (OutputStreamType)localAccepts, (OutputStreamType)globalAccepts);
listener.LocalAuthorizationRequired = localAuthorizationRequired;
listener.GlobalAuthorizationRequired = globalAuthorizationRequired;
owner.Application.SaveSettings();
return GetListener(listener);
}