bare basic WS setup
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Maui.Hosting;
|
||||
using WebSocketSharp;
|
||||
|
||||
namespace RelayClient;
|
||||
|
||||
public static class MauiProgram
|
||||
{
|
||||
// public static event Action<ChatMessage>? MessageSent;
|
||||
public static WebSocket wsc = new WebSocket("ws://localhost:1337");
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
wsc.OnMessage += (sender, e) => OnWebSocketRecieved(sender, e);
|
||||
wsc.Connect();
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.ConfigureFonts(fonts =>
|
||||
builder.UseMauiApp<App>().ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("AnonymousPro-Bold.ttf", "AnonymousProBold");
|
||||
fonts.AddFont("AnonymousPro-BoldItalic.ttf", "AnonymousProBoldItalic");
|
||||
fonts.AddFont("AnonymousPro-Italic.ttf", "AnonymousProItalic");
|
||||
fonts.AddFont("AnonymousPro-Regular.ttf", "AnonymousProRegular");
|
||||
});
|
||||
|
||||
|
||||
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
@@ -24,4 +28,20 @@ public static class MauiProgram
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static void OnWebSocketRecieved(object? sender, MessageEventArgs e)
|
||||
{
|
||||
Console.WriteLine(sender.ToString());
|
||||
|
||||
ChatSimulator.Send(e.Data.Split(":")[0], e.Data.Split(":")[1]);
|
||||
|
||||
// var message = new ChatMessage
|
||||
// {
|
||||
// SenderUsername = e.Data.Split(":")[0],
|
||||
// Text = e.Data.Split(":")[1],
|
||||
// Timestamp = DateTime.Now
|
||||
// };
|
||||
//
|
||||
// MessageSent?.Invoke(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user