Table of Contents

Class ChatClient

Namespace
UdpChat.Client
Assembly
UdpChat.Client.dll

A ChatClient is a client for the chat system.

public class ChatClient
Inheritance
ChatClient
Inherited Members

Constructors

ChatClient(int, string, int)

Initializes a new instance of the ChatClient class with the specified client port and central server IP and port.

public ChatClient(int clientPort = 4000, string centralServerIP = "127.0.0.1", int centralServerPort = 5000)

Parameters

clientPort int

The port number to use for the client.

centralServerIP string

The IP address of the central server.

centralServerPort int

The port number to use for the central server.

Exceptions

ArgumentException

Thrown if the receive socket's local endpoint is null.

Fields

user

public ChatUser? user

Field Value

ChatUser

ChatUser instance representing this ChatClient

Properties

MessageListenerService

public ServerService MessageListenerService { get; set; }

Property Value

ServerService

Methods

PingCentralServer()

Pings the central server to check if it is reachable

public bool PingCentralServer()

Returns

bool

true if the central server can be reached, false if not

ReceiveCallback(IAsyncResult)

public void ReceiveCallback(IAsyncResult ar)

Parameters

ar IAsyncResult

SendAuthRequest(string, string, RequestType)

Sends a an auth request of type Request.RequestType to the central server.

public void SendAuthRequest(string username, string password, Request.RequestType type)

Parameters

username string
password string
type Request.RequestType

SendMessage(string)

Sends a message if the user is logged in to the central server.

public void SendMessage(string msg)

Parameters

msg string

StartMessageService()

public void StartMessageService()