HTML and CSS Reference
In-Depth Information
// Store the subscribed clients.
var clients = new
List<IWebSocketConnection>();
// Initialize the WebSocket server
connection.
var server = new
WebSocketServer("ws://localhost:8181");
server.Start(socket) =>
{
socket.OnOpen = () =>
{
// Add the incoming connection to our
list.
clients.Add(socket);
// Inform the others that someone has
just joined the conversation.
foreach (var client in clients)
{
// Check the connection unique ID
and display a different welcome message!
if (client.ConnectionInfo.Id !=
socket.ConnectionInfo.Id)
{
client.Send("<i>" +
socket.ConnectionInfo.Id + " joined the
conversation.</i>");
}
else
{
client.Send("<i>You have just
joined the conversation.</i>");
}
}
};
Search WWH ::




Custom Search