This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task SendMessage(string x, string y) | |
| { | |
| await Clients.All.SendAsync("ReceiveMessage", Context.ConnectionId, x, y); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.nextjs = { | |
| addMouseEventListener: function () { | |
| window.addEventListener('mousemove', (e) => { | |
| const data = { | |
| X: e.clientX.toString(), | |
| Y: e.clientY.toString(), | |
| }; | |
| DotNet.invokeMethodAsync( | |
| 'NextJSConf.Client', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [JSInvokable] | |
| public static void CaptureMouseEvents(string data) | |
| { | |
| var cursorInfo = System.Text.Json.JsonSerializer.Deserialize<Cursor>(data); | |
| func(cursorInfo); | |
| } | |
| public async Task SendMouseEvents(Cursor cursorInfo) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected override async Task OnInitializedAsync() | |
| { | |
| hubConnection = new HubConnectionBuilder() | |
| .WithUrl(NavigationManager.ToAbsoluteUri("/clienthub")) | |
| .Build(); | |
| hubConnection.On<string, string, string>("ReceiveMessage", (connectionId, x, y) => | |
| { | |
| JSRuntime.InvokeVoidAsync("nextjs.updateCursor", connectionId, x, y); | |
| StateHasChanged(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| const colors = [ | |
| '#f44336', | |
| '#e91e63', | |
| '#9c27b0', | |
| '#673ab7', | |
| '#3f51b5', | |
| '#009688', | |
| '#ffeb3b', | |
| '#795548', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @page "/" | |
| @using Microsoft.AspNetCore.SignalR.Client | |
| @inject NavigationManager NavigationManager | |
| @implements IAsyncDisposable | |
| @inject IJSRuntime JSRuntime; | |
| <div class="container py-4"> | |
| <div class="row align-items-md-stretch"> | |
| <div class="col-md-8" style="border: 1px solid white;"> | |
| <div class="h-100 p-5 text-white rounded-3"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.SignalR; | |
| namespace NextJSConf.Server.Hubs | |
| { | |
| public static class ConnectedClients | |
| { | |
| public static List<string> ConnectedClientIds = new List<string>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddRazorPages(); | |
| services.AddServerSideBlazor(); | |
| services.AddSingleton<WeatherForecastService>(); | |
| services.AddGrpcClient<LocationData.LocationDataClient>(client => | |
| { | |
| client.Address = new Uri("http://localhost:80"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
| { | |
| app.UseEndpoints(endpoints => | |
| { | |
| endpoints.MapGrpcService<LocationService>(); | |
| if (env.IsDevelopment()) | |
| { | |
| endpoints.MapGrpcReflectionService(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @page "/mapbox" | |
| @using Grpc.Core | |
| @using GPRCStreaming | |
| @using System.Diagnostics | |
| @inject IJSRuntime JSRuntime; | |
| @inject System.Net.Http.IHttpClientFactory _clientFactory | |
| @inject GPRCStreaming.LocationData.LocationDataClient LocationDataClient |