Code Monkey home page Code Monkey logo

blazorchatsample's Introduction

About Me

A real dinosaur on the bleeding edge of web design. Use Visual Studio and VS Code to create ASP.NET and ASP.NET Core applications.

A fan of Blazor since it first appeared and using it real applications already.

๐Ÿ“ฆ Notable GitHub Repos

Libraries

  • BlazorTemplater renders .razor components to HTML - useful for email generation.
  • BlazorFormLayout Blazor component library to make creating Bootstrap v4 forms easier
  • Frankfurter C# API for the Frankfurter currency conversion web service
  • versionReaderTask Azure DevOps build task to extract version values from projects

Demo Apps

โœ๏ธ Blog

Blazor Expert

๐Ÿ“Š GitHub Stats

conficient's GitHub stats

blazorchatsample's People

Contributors

conficient avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blazorchatsample's Issues

Add 'joined' and 'left' messages

Client should send a message "{user} joined the chat" on connecting, and "{user} left the chat" on disconnecting.

I did try to implement this in the original version, but had SignalR errors. I suspect the chat connecting had not completed when connecting (I think the .start() method may return a promise?).

Modify methods used in client to be async

At present the Start(), Send() and Stop() methods are all synchronous, but it's likely the underlying js methods are async, returning promises.

Need to rewrite ChatClient to be async and amend chatClient.js to match.

Can't connect to blazor server from console app

I have blazor sample working, and can start chats etc, but I am wanting to connect a console app to the same chat hub on the same pc, but cannot.

Here is the sample code
` private static void Main(string[] args)
{
Console.WriteLine("Starting App...");

        //Set connection
        //var connection = new HubConnection("http://127.0.0.1:6836/");
        var connection = new HubConnection("http://localhost:6836");
        //Make proxy to hub based on hub name on server
        var myHub = connection.CreateHubProxy("/ChatHub");
        //Start connection

        Console.WriteLine("Starting Connection");

        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine("Sleeping...");
            Thread.Sleep(1000);
        }

        myHub.On<string>("addMessage", param => {
            Console.WriteLine(param);
        });

        connection.Start().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Console.WriteLine("There was an error opening the connection:{0}",
                                  task.Exception.GetBaseException());
            }
            else
            {
                Console.WriteLine("Connected");
            }

        }).Wait();
        

        for (int i = 0; i < 5;i++)
            {
            Console.WriteLine("Sleeping...");
            Thread.Sleep(1000);
            }        

        myHub.Invoke<string>("Send", "HELLO World ").ContinueWith(task => {
            if (task.IsFaulted)
            {
                Console.WriteLine("There was an error calling send: {0}",
                                  task.Exception.GetBaseException());
            }
            else
            {
                Console.WriteLine(task.Result);
            }
        });

`

The error is
There was an error opening the connection:Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonTextReader.ReadInternal()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<>c.b__0_1(String raw) in //src/Microsoft.AspNet.SignalR.Client/Transports/TransportHelper.cs:line 43
at Microsoft.AspNet.SignalR.TaskAsyncHelper.<>c__DisplayClass31_02.<Then>b__0(Task1 t) in /
/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs:line 494
at Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners2.<>c__DisplayClass3_0.<RunTask>b__0(Task1 t) in /_/src/Microsoft.AspNet.SignalR.Core/TaskAsyncHelper.cs:line 1280

Any clues as to what I am doing wrong ?

UI layout and CSS needs improvement

A few issues to fix:

  • the disconnect button isn't visible on xs view mode
  • the chat box and Send button are not aligned
  • the chat box should be in a fixed footer so it does not scroll as the messages arrive
  • should support Enter in chat box so you don't have to click send
  • chat box should focus after a message so chat can continue

How to run?

The project cannot be opened in visual studio and when i try to run with dotnet run i get this error that only happens with this application:
Found .NET Core SDK, but did not find dotnet.dll at [C:\Program Files\dotnet\sdk\3.1.100\dotnet.dll]

private chat

as I understand it this is a public chat, where anyone who enters talks with everyone. don't have a way to make a hub between two people only?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.