(**) 我创建了一个 ASP.NET Web 服务器,托管 SignalR 集线器。我跟着这个 教程。有用。然后我创建了一个 Xamarin.Android 客户端(*)。问题是我无法连接到服务器。我想,由于主机地址中的“localhost”,我无法连接。例外是相当大的。
如果我的怀疑是正确的,我该如何解决?如何使本地主机看起来像普通服务器?
(*) - 我也尝试过使用 Xamarin.Forms。
(**) - 请看问题底部的“编辑”。
这是我的方法:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += async delegate
{
button.Text = string.Format("{0} clicks!", count++);
var hubConnection = new HubConnection("http://localhost:64642");
var chatHubProxy = hubConnection.CreateHubProxy("ChatHub");
try
{
// Start the …Run Code Online (Sandbox Code Playgroud)