Chat Sample (.NET)

In this tutorial we will build a small chat application — a server and a client — entirely from scratch, using the Code-First approach. The service interfaces are defined directly in code; the client then imports them from the running server, so no RODL is authored by hand.

Remoting SDK ships with project templates for both Code-First and RODL-based servers, but here we intentionally start from an empty Windows Forms project, so that every moving part stays visible.

By the end you will have a working chat where several clients can log in, exchange messages and receive updates pushed from the server in real time.

What the sample demonstrates

  • Hosting a server with the ApplicationServer bootstrapper (console, GUI and Windows Service modes)
  • Defining services in code with the [Service] and [ServiceMethod] attributes
  • Session-based authentication (LoginService) and login-protected services ([ServiceRequiresLogin])
  • Server-sent events to push messages from the server to all connected clients
  • Importing the server interface into a client and calling services through asynchronous proxies

Chapters

  1. Sample Server - Bootstrapper — create the server host
  2. Sample Server - Services — add the Login and Chat services
  3. Sample Client — build the client and call the services
  4. Sample Server - Sending data to the client — add server-sent events
  5. Sample Client - Receiving data from the server — handle the events in the client

The sample is a .NET Framework Windows Forms application; the full source code is attached to the individual chapters.