Fix for the secure connection
parent
49dc8800d3
commit
3e6c589953
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="ServerCertPath" value="/path/to/server.cer" />
|
<add key="ServerCertFile" value="/path/to/cert.pfx"/>
|
||||||
|
<add key="CertFilePassword" value="password"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -1,58 +1,67 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using WebSocketSharp;
|
using WebSocketSharp;
|
||||||
using WebSocketSharp.Server;
|
using WebSocketSharp.Server;
|
||||||
|
|
||||||
namespace Example2
|
namespace Example2 {
|
||||||
{
|
|
||||||
public class Program
|
public class Program {
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
public static void Main (string [] args)
|
||||||
{
|
{
|
||||||
/* Single service server
|
/* Single service server
|
||||||
//var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649");
|
var wssv = new WebSocketServiceHost<Echo> ("ws://localhost:4649");
|
||||||
var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649/Echo");
|
//var wssv = new WebSocketServiceHost<Echo> ("ws://localhost:4649/Echo");
|
||||||
//var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649/エコー");
|
//var wssv = new WebSocketServiceHost<Echo> ("ws://localhost:4649/エコー");
|
||||||
//var wssv = new WebSocketServiceHost<Echo>(4649);
|
//var wssv = new WebSocketServiceHost<Echo> (4649);
|
||||||
//var wssv = new WebSocketServiceHost<Echo>(4649, "/Echo");
|
//var wssv = new WebSocketServiceHost<Echo> (4649, "/Echo");
|
||||||
//var wssv = new WebSocketServiceHost<Echo>(4649, "/エコー");
|
//var wssv = new WebSocketServiceHost<Echo> (4649, "/エコー");
|
||||||
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649");
|
//var wssv = new WebSocketServiceHost<Chat> ("ws://localhost:4649");
|
||||||
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649/Chat");
|
//var wssv = new WebSocketServiceHost<Chat> ("ws://localhost:4649/Chat");
|
||||||
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649/チャット");
|
//var wssv = new WebSocketServiceHost<Chat> ("ws://localhost:4649/チャット");
|
||||||
//var wssv = new WebSocketServiceHost<Chat>(4649);
|
//var wssv = new WebSocketServiceHost<Chat> (4649);
|
||||||
//var wssv = new WebSocketServiceHost<Chat>(4649, "/Chat");
|
//var wssv = new WebSocketServiceHost<Chat> (4649, "/Chat");
|
||||||
//var wssv = new WebSocketServiceHost<Chat>(4649, "/チャット");
|
//var wssv = new WebSocketServiceHost<Chat> (4649, "/チャット");
|
||||||
//wssv.Sweeping = false; // Stop the sweep inactive session timer.
|
#if DEBUG
|
||||||
|
wssv.Log.Level = LogLevel.TRACE;
|
||||||
wssv.Start();
|
#endif
|
||||||
Console.WriteLine(
|
//wssv.Sweeping = false;
|
||||||
|
|
||||||
|
wssv.Start ();
|
||||||
|
Console.WriteLine (
|
||||||
"WebSocket Service Host (url: {0})\n listening on address: {1} port: {2}\n",
|
"WebSocket Service Host (url: {0})\n listening on address: {1} port: {2}\n",
|
||||||
wssv.Uri, wssv.Address, wssv.Port);
|
wssv.Uri, wssv.Address, wssv.Port);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Multi services server
|
/* Multi services server */
|
||||||
var wssv = new WebSocketServer(4649);
|
var wssv = new WebSocketServer (4649);
|
||||||
//var wssv = new WebSocketServer("ws://localhost:4649");
|
//var wssv = new WebSocketServer (4649, true);
|
||||||
|
//var wssv = new WebSocketServer ("ws://localhost:4649");
|
||||||
|
//var wssv = new WebSocketServer ("wss://localhost:4649");
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
wssv.Log.Level = LogLevel.TRACE;
|
wssv.Log.Level = LogLevel.TRACE;
|
||||||
#endif
|
#endif
|
||||||
//wssv.Sweeping = false; // Stop the sweep inactive session timer.
|
//var file = ConfigurationManager.AppSettings ["ServerCertFile"];
|
||||||
wssv.AddWebSocketService<Echo>("/Echo");
|
//var password = ConfigurationManager.AppSettings ["CertFilePassword"];
|
||||||
wssv.AddWebSocketService<Chat>("/Chat");
|
//wssv.Certificate = new X509Certificate2 (file, password);
|
||||||
//wssv.AddWebSocketService<Echo>("/エコー");
|
//wssv.Sweeping = false;
|
||||||
//wssv.AddWebSocketService<Chat>("/チャット");
|
wssv.AddWebSocketService<Echo> ("/Echo");
|
||||||
|
wssv.AddWebSocketService<Chat> ("/Chat");
|
||||||
wssv.Start();
|
//wssv.AddWebSocketService<Echo> ("/エコー");
|
||||||
Console.WriteLine(
|
//wssv.AddWebSocketService<Chat> ("/チャット");
|
||||||
|
|
||||||
|
wssv.Start ();
|
||||||
|
Console.WriteLine (
|
||||||
"WebSocket Server listening on port: {0} service path:", wssv.Port);
|
"WebSocket Server listening on port: {0} service path:", wssv.Port);
|
||||||
foreach (var path in wssv.ServicePaths)
|
foreach (var path in wssv.ServicePaths)
|
||||||
Console.WriteLine(" {0}", path);
|
Console.WriteLine (" {0}", path);
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("Press any key to stop server...");
|
Console.WriteLine ();
|
||||||
Console.ReadLine();
|
Console.WriteLine ("Press enter key to stop server...");
|
||||||
|
Console.ReadLine ();
|
||||||
|
|
||||||
wssv.Stop();
|
wssv.Stop ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue