I have a project I am currently working on and I need users to be able to chat online amongst themselves. Please experts, what are the basics I need to know and implement so that this becomes possible.:?: :cool:

Dani AI

Generated

A concise, modern checklist that complements ’s port question and ’s “shout box” suggestion.

A web chat has three practical layers: transport, server logic, and client UI. For transport, prefer WebSockets (or SignalR in .NET for an easier API and fallbacks) so the server can push messages in real time; WebSocket connections use the same HTTP ports (ws on 80, wss on 443), so opening new arbitrary ports is not required and is usually undesirable behind firewalls or typical hosting. A simple “shout box” can be built with periodic AJAX polling, but SignalR/WebSockets scale and reduce latency.

Server responsibilities: authenticate and authorize, validate and sanitize incoming text (prevent XSS), apply rate limits and moderation rules, persist history if needed, and broadcast to relevant rooms/groups. Use a compact JSON message model with fields such as roomId, userId, text, timestamp, and a messageId for ordering and deduplication. For .NET, an idiomatic server-side piece is a SignalR Hub that broadcasts validated messages to a group.

Example (ASP.NET Core SignalR-style hub):

public class ChatHub : Hub
{
    public async Task SendMessage(string room, string user, string message)
    {
        var safe = HtmlEncoder.Default.Encode(message);
        await Clients.Group(room).SendAsync("ReceiveMessage", user, safe, DateTime.UtcNow);
    }
}

Scaling and deployment notes: use TLS (wss) for pages served over HTTPS; avoid mixed content. For multi-server deployments enable a backplane (Redis or the Azure SignalR Service) instead of relying on sticky sessions. Add health checks, logging, and client reconnect/heartbeat logic. For a practical starting point and API details, consult the official ASP.NET Core SignalR documentation (ASP.NET Core SignalR introduction).

Recommended Answers

All 2 Replies

Hello experts!
I believe there's someone out there with an idea on how I start off on this project. I know that there would be a server and a client module. Since it is a webbased app what port do I listen to and how do I go about it?:)

try doing a search for "shout box" it's a simple realtime message posting thing-a-ma-jigg. if you need something more advance then just search around for opensource chat scripts

commented: thanks man! t'was just what i needed. +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.