Hi,
Is there any possible way to talk with UWP? I did two classes for comm. but data first few bytes are correct, then its gonna wrong. I have no idea why is that happening.
I used WebSockets with following code:
UWP: http://pastebin.com/qtXULST1 (comm class)
UWP MainPage init:
private void InitializeWebSocket() { Uri server = new Uri("ws://localhost:5000/ws"); communication = new Communication(server); communication.OnReceivedData += Comm_OnReceivedData; } private void Comm_OnReceivedData(object sender, ReceivedDataArgs e) { object data = e.Data; switch(e.Opcode) { case PacketData.Opcodes.Hello: { string hello = data as string; } break; case PacketData.Opcodes.Close: { } break; } }
ASP.NET rc2 comm class: http://pastebin.com/vscXjjbm
ASP.NET startup.cs:
public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseStaticFiles(); app.UseWebSockets(); app.Map("/ws", builder => { builder.Use(async (context, next) => { if(context.WebSockets.IsWebSocketRequest) { var socket = await context.WebSockets.AcceptWebSocketAsync(); if(socket != null && socket.State == System.Net.WebSockets.WebSocketState.Open) { Communication comm = new Communication(socket); if (DaisyConfig.WebSocket == null || DaisyConfig.WebSocket.Socket.State != System.Net.WebSockets.WebSocketState.Open) DaisyConfig.WebSocket = comm; } } await next(); }); }); }
Read in UWP results in exception, that data couldn't be read.
Thanks for any help!