HTML and CSS Reference
In-Depth Information
using System.Net.Sockets;
namespace WsServer
// This class defines the data that is passed to the MessageReceived
// event handler
public class MessageReceivedEventArgs
public string Message { get; private set; }
public int DataLength { get; private set; }
public MessageReceivedEventArgs(string msg, int len)
// Define the event handler delegates
public delegate void MessageReceivedEventHandler
(WsConnection sender, MessageReceivedEventArgs e);
public delegate void WsDisconnectedEventHandler
(WsConnection sender, EventArgs e);
public class WsConnection : IDisposable
#region Members
public Socket _mySocket;
protected byte[] _inputBuffer;
protected StringBuilder _inputString;
// Define the events that are available
public event MessageReceivedEventHandler MessageReceived;
public event WsDisconnectedEventHandler Disconnected;
#endregion Members
public WsConnection(Socket s)
_inputBuffer=new byte[255];
_inputString=new StringBuilder();
// Begin listening - the ReadMessage() method will be
// invoked when a message is received.
Search WWH ::

Custom Search