Initial connect testing

pull/702/head
Eric Reed 10 years ago
parent 6f45ea0823
commit 6fd05670ac

@ -96,11 +96,11 @@ namespace MediaBrowser.Server.Implementations.Connect
if (hasExistingRecord) if (hasExistingRecord)
{ {
//await UpdateServerRegistration(wanApiAddress).ConfigureAwait(false); await UpdateServerRegistration(wanApiAddress).ConfigureAwait(false);
} }
else else
{ {
//await CreateServerRegistration(wanApiAddress).ConfigureAwait(false); await CreateServerRegistration(wanApiAddress).ConfigureAwait(false);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -113,10 +113,9 @@ namespace MediaBrowser.Server.Implementations.Connect
{ {
var url = "Servers"; var url = "Servers";
url = GetConnectUrl(url); url = GetConnectUrl(url);
url += "?Name=" + WebUtility.UrlEncode(_appHost.FriendlyName); var postData = new Dictionary<string, string> {{"name", _appHost.FriendlyName}, {"url", wanApiAddress}};
url += "&Url=" + WebUtility.UrlEncode(wanApiAddress);
using (var stream = await _httpClient.Post(url, new Dictionary<string, string>(), CancellationToken.None).ConfigureAwait(false)) using (var stream = await _httpClient.Post(url, postData, CancellationToken.None).ConfigureAwait(false))
{ {
var data = _json.DeserializeFromStream<ServerRegistrationResponse>(stream); var data = _json.DeserializeFromStream<ServerRegistrationResponse>(stream);
@ -129,15 +128,15 @@ namespace MediaBrowser.Server.Implementations.Connect
private async Task UpdateServerRegistration(string wanApiAddress) private async Task UpdateServerRegistration(string wanApiAddress)
{ {
var url = "Servers/" + ConnectServerId; var url = "Servers";
url = GetConnectUrl(url); url = GetConnectUrl(url);
url += "?Name=" + WebUtility.UrlEncode(_appHost.FriendlyName); url += "?id=" + ConnectServerId;
url += "&Url=" + WebUtility.UrlEncode(wanApiAddress); var postData = new Dictionary<string, string> {{"name", _appHost.FriendlyName}, {"url", wanApiAddress}};
// TODO: Add AccessKey http request header // TODO: Add Access-Key http request header
// No need to examine the response // No need to examine the response
using (var stream = await _httpClient.Post(url, new Dictionary<string, string>(), CancellationToken.None).ConfigureAwait(false)) using (var stream = await _httpClient.Post(url, postData, CancellationToken.None).ConfigureAwait(false))
{ {
} }
} }
@ -198,7 +197,7 @@ namespace MediaBrowser.Server.Implementations.Connect
private string GetConnectUrl(string handler) private string GetConnectUrl(string handler)
{ {
return "http://mediabrowser.tv:8095/" + handler; return "http://mb3admin.com/test/connect/" + handler;
} }
} }
} }

Loading…
Cancel
Save