using System;
using System.Configuration;
using System.Security.Cryptography.X509Certificates;
using WebSocketSharp;
using WebSocketSharp.Net;
using WebSocketSharp.Server;
namespace Example2
{
public class Program
{
public static void Main (string[] args)
{
// Create a new instance of the WebSocketServer class.
//
// If you would like to provide the secure connection, you should
// create a new instance with the "secure" parameter set to true or
// with a wss scheme WebSocket URL.
var wssv = new WebSocketServer (4649);
//var wssv = new WebSocketServer (5963, true);
//var wssv = new WebSocketServer (System.Net.IPAddress.Any, 4649);
//var wssv = new WebSocketServer (System.Net.IPAddress.Any, 5963, true);
//var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Any, 4649);
//var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Any, 5963, true);
//var wssv = new WebSocketServer ("ws://0.0.0.0:4649");
//var wssv = new WebSocketServer ("wss://0.0.0.0:5963");
//var wssv = new WebSocketServer ("ws://[::0]:4649");
//var wssv = new WebSocketServer ("wss://[::0]:5963");
//var wssv = new WebSocketServer (System.Net.IPAddress.Loopback, 4649);
//var wssv = new WebSocketServer (System.Net.IPAddress.Loopback, 5963, true);
//var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Loopback, 4649);
//var wssv = new WebSocketServer (System.Net.IPAddress.IPv6Loopback, 5963, true);
//var wssv = new WebSocketServer ("ws://localhost:4649");
//var wssv = new WebSocketServer ("wss://localhost:5963");
//var wssv = new WebSocketServer ("ws://127.0.0.1:4649");
//var wssv = new WebSocketServer ("wss://127.0.0.1:5963");
//var wssv = new WebSocketServer ("ws://[::1]:4649");
//var wssv = new WebSocketServer ("wss://[::1]:5963");
#if DEBUG
// To change the logging level.
wssv.Log.Level = LogLevel.Trace;
// To provide the HTTP Authentication (Basic/Digest).
/*
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
wssv.Realm = "WebSocket Test";
wssv.UserCredentialsFinder =
id => {
var name = id.Name;
// Return user name, password, and roles.
return name == "nobita"
? new NetworkCredential (name, "password", "gunfighter")
: null; // If the user credentials are not found.
};
*/
// To remove the inactive sessions periodically.
//wssv.KeepClean = true;
// To resolve to wait for socket in TIME_WAIT state.
//wssv.ReuseAddress = true;
// To provide the secure connection.
/*
var cert = ConfigurationManager.AppSettings["ServerCertFile"];
var passwd = ConfigurationManager.AppSettings["CertFilePassword"];
wssv.SslConfiguration.ServerCertificate = new X509Certificate2 (
cert,
passwd
);
*/
// To change the wait time for the response to the WebSocket Ping or Close.
//wssv.WaitTime = TimeSpan.FromSeconds (2);
#endif
// Add the WebSocket services.
wssv.AddWebSocketService