Provides the networking client functionality to send and receive any data object.
View code on GitHub
Namespace: DeltaEngine.NetworkingAssembly: DeltaEngine.Networking (in DeltaEngine.Networking.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Client type exposes the following members.
Methods
Name | Description | |
---|---|---|
Connect | ||
Send |
Properties
Name | Description | |
---|---|---|
IsConnected | ||
TargetAddress | ||
UniqueID |
Events
Name | Description | |
---|---|---|
Connected | ||
DataReceived | ||
Disconnected |
Remarks
Examples
[Test] public void ConnectToServer() { var server = new MockServer(); using (var client = new MockClient(server)) { client.Connect("localhost", 1); Assert.IsTrue(client.IsConnected); } }
[Test] public void SendTestMessageWithoutServerShouldNotCrash() { using (var client = new MockClient(null)) { Assert.IsFalse(client.IsConnected); client.Send(new TextMessage("")); } }
[Test] public void ConvertBinaryDataToArray() { var server = new MockServer(); Assert.IsNull(server.LastMessage); var client = new MockClient(server); client.Connect("localhost", 1); client.Send(new TextMessage("Hi")); var serverMessage = server.LastMessage as TextMessage; byte[] byteArray = BinaryDataExtensions.ToByteArrayWithLengthHeader(serverMessage); int classNameLength = "TestMessage".Length + StringLengthByte; int textLength = "Hi".Length + StringLengthByte + StringIsNullBooleanByte; Assert.AreEqual(LengthOfNetworkMessage + LengthOfDataVersion + classNameLength + textLength, byteArray.Length); }
See Also