我的服務器和自定義測試客戶端之間的通信正在工作。SignalR不能在windows上使用覆盆子10
我從我的UWP添加一個連接,並在我的本地窗口上運行它,它正在工作。
當我將我的UWP部署在運行win iot核心的樹莓上時,信號未收到,輸出中未顯示錯誤。
服務器:
class Program
{
static void Main(string[] args)
{
// This will *ONLY* bind to localhost, if you want to bind to all addresses
// use http://*:8080 to bind to all addresses.
// See http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
// for more information.
string url = "http://localhost:8080";
using (WebApp.Start<Startup>(url))
{
Console.WriteLine("Server running on {0}", url);
Console.ReadLine();
}
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR();
}
}
TestClient的:
public class Program
{
public static void Main(string[] args)
{
//Set connection
string url = "http://localhost:8080";
var connection = new HubConnection(url);
//Make proxy to hub based on hub name on server
var myHub = connection.CreateHubProxy("TestHub");
//Start connection
connection.Start();
while (true)
{
Console.ReadLine();
myHub.Invoke("SendSignal");
}
}
}
UWP APP:
InitializeComponent();
pushButtonValue = GpioPinValue.High;
InitGPIO();
//Set connection
string url = "http://localhost:8080";
var connection = new HubConnection(url);
//Make proxy to hub based on hub name on server
var myHub = connection.CreateHubProxy("TestHub");
//Start connection
myHub.On("ReceiveSignal", FlipLED);
connection.Start();
//timer = new DispatcherTimer();
//timer.Interval = TimeSpan.FromMilliseconds(50);
//timer.Tick += Timer_Tick;
//timer.Start();
我不知道到c嘿/做下一個。
爲什麼當我的應用在我的PI上運行時收不到消息?
可以在服務器端捕獲數據包以查看客戶端是否連接到它。檢查併發布您找到的內容。 –