Server ClassDelta Engine Documentation
Servers listen on a specific port and accept multiple clients. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Networking Server
    DeltaEngine.Networking.Mocks MockServer
    DeltaEngine.Networking.Tcp TcpServer

Namespace: DeltaEngine.Networking
Assembly: DeltaEngine.Networking (in DeltaEngine.Networking.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public abstract class Server : IDisposable

The Server type exposes the following members.

Constructors

  NameDescription
Protected methodServer
Initializes a new instance of the Server class
Top
Methods

  NameDescription
Public methodDispose
Public methodOnClientDataReceived
Protected methodRaiseClientConnected
Protected methodRaiseClientDisconnected
Public methodStart
Top
Fields

  NameDescription
Protected fieldconnectedClients
Top
Properties

  NameDescription
Public propertyIsRunning
Public propertyListenPort
Public propertyNumberOfConnectedClients
Top
Events

  NameDescription
Public eventClientConnected
Public eventClientDataReceived
Public eventClientDisconnected
Top
Remarks

Tests: DeltaEngine.Networking.Tests.ServerTests
Examples

5 unit tests call DeltaEngine.Networking.Server
[Test]
public void ListenForClients()
{
    server.Start(800);
    Assert.IsTrue(server.IsRunning);
}
[Test]
public void InitiallyNoClients()
{
    Assert.AreEqual(0, server.ListenPort);
    Assert.AreEqual(0, server.NumberOfConnectedClients);
}
[Test]
public void ConnectClient()
{
    bool didClientConnect = false;
    server.ClientConnected += client => didClientConnect = true;
    CreateConnectedClient();
    Assert.AreEqual(1, server.NumberOfConnectedClients);
    Assert.IsTrue(didClientConnect);
}
See Also