Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions AlphabotHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;

public enum MovementStatus
{
Stopped,
Foeward,
Backward,
Left,
Right,
}

public interface IAlphabotController
{
Task OnMovementStatusChanged(MovementStatus status);
}

public class AlphabotHub : Hub<IAlphabotController>
{/*
public override Task OnConnectedAsync()
{
//return Clients.All.SendAsync("sendToAll", "__ADMIN__", $"{Context.ConnectionId} joined");

}

public override Task OnDisconnectedAsync(Exception exception)
{
//return Clients.All.SendAsync("sendToAll", "__ADMIN__", $"{Context.ConnectionId} left");
}
*/
public Task StopAsync()
{
//return Clients.All.SendAsync("sendToAll", "__ECHO_BACK__", message);


_ = Task.Run(() => Clients.All.OnMovementStatusChanged(MovementStatus.Stopped));

return Task.CompletedTask;
}


}
2 changes: 1 addition & 1 deletion MyChatHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.SignalR;


public class MyHub : Hub
public class MyChatHub : Hub
{
public override Task OnConnectedAsync()
{
Expand Down
3 changes: 2 additions & 1 deletion Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseSignalR(routes =>
{
routes.MapHub<MyHub>("/chat");
routes.MapHub<MyChatHub>("/chat");
routes.MapHub<AlphabotHub>("/alphabot");
});
// app.Run(async (context) =>
// {
Expand Down