HTML and CSS Reference
In-Depth Information
Listing 13-9. Implementing the WsClientConnection class
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
namespace WsServer
public delegate void WsDisconnectedClientEventHandler
(WsClientConnection sender, EventArgs e);
public class WsClientConnection : IDisposable
private WsConnection _connection;
public string _name;
public WsAgentConnection _agent;
public int _clientID;
public event WsDisconnectedClientEventHandler ClientDisconnected;
public WsClientConnection(WsConnection conn,
WsAgentConnection agent,
int id,
string name)
public void MessageReceived(WsConnection sender,
MessageReceivedEventArgs e)
if (_agent != null)
_agent.SendMessage(_clientID.ToString()+": "+e.Message);
public void SendMessage(string msg)
if (_connection != null)
public void Disconnected(WsConnection sender, EventArgs e)
if (ClientDisconnected != null)
ClientDisconnected(this, EventArgs.Empty);
Search WWH ::

Custom Search