konsole
konsole copied to clipboard
REMOTE KONSOLE - SignalR/server send events React "Konsole"
SignalR/server send events React "Konsole"
The idea is to be able to drop in a text console "widget" into a webpage, e.g. a React control, or even in a static CDN website, that loads a console with a unique session ID, app ID and string[] channels. Then be able to treate writing to a remote console as simple as writing to a konsole window, with some extra support for broadcasting to channels, as well as processing user input.
for example, in a game; where the statusbar channel, is defined client side using normal console commands, window.SplitLeft(), splitColumns
for example
// below code would be converted to javascript / react so shown only as pseduo code for converting to react.
var rows = layout.SplitRows(
new Split(3, "headline", LineThickNess.Single, ConsoleColor.Yellow),
new Split(0, "content", LineThickNess.Single),
new Split(3, "status", LineThickNess.Single, ConsoleColor.Yellow)
);
var rc = new remoteConsole(appId, appUrl, authtoken);
var header = new remoteConsole(rc, rows[0], "header");
var content = new remoteConsole(rc, rows[1],"content");
var status = new remoteConsole(rc, rows[2], "statusBar");
rc.Render();
rc.HandleEvents(myCancellationToken);
then server side you can write
var (deadUser, restOfUsers) = GetNextVictim(); // returns sessionIDs used to communicate with remote users.
var rc = new RemoteConsole(appId, appUrl, token);
var contentAll = rc.BroadCast.ToChannel("content").ToAllExcluding(deadUser.SessionId);
contentAll.WriteLine(Yellow, $"{deadUser.Name} was killed by the wearwolf.");
var contentDead = rc.SingleCast(deadUser.SessionId).ToChannel("content"):
contentDead.WriteLine(Red, $"You have been killed by the wearwolf.");
var statusAll = rc.BroadCast.ToChannel("status");
statusAll.WriteLine($"Only {cnt} players left alive!");