2012-08-04 14:51:31 +08:00
|
|
|
using System;
|
2012-08-06 13:34:39 +08:00
|
|
|
using WebSocketSharp.Server;
|
2012-08-04 14:51:31 +08:00
|
|
|
|
2012-08-06 13:34:39 +08:00
|
|
|
namespace Example2
|
2012-08-04 14:51:31 +08:00
|
|
|
{
|
|
|
|
public class Program
|
|
|
|
{
|
2012-08-06 13:34:39 +08:00
|
|
|
public static void Main(string[] args)
|
2012-08-04 14:51:31 +08:00
|
|
|
{
|
2012-10-01 14:26:31 +08:00
|
|
|
/* Single service server
|
2012-10-23 14:39:31 +08:00
|
|
|
//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/エコー");
|
|
|
|
//var wssv = new WebSocketServiceHost<Echo>(4649);
|
|
|
|
//var wssv = new WebSocketServiceHost<Echo>(4649, "/Echo");
|
|
|
|
//var wssv = new WebSocketServiceHost<Echo>(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/チャット");
|
|
|
|
//var wssv = new WebSocketServiceHost<Chat>(4649);
|
|
|
|
//var wssv = new WebSocketServiceHost<Chat>(4649, "/Chat");
|
|
|
|
//var wssv = new WebSocketServiceHost<Chat>(4649, "/チャット");
|
2012-10-26 13:58:50 +08:00
|
|
|
//wssv.Sweeped = false; // Stop the Sweep inactive session Timer.
|
2012-08-04 14:51:31 +08:00
|
|
|
|
|
|
|
wssv.Start();
|
|
|
|
Console.WriteLine(
|
2012-10-23 14:39:31 +08:00
|
|
|
"WebSocket Service Host (url: {0})\n listening on address: {1} port: {2}\n",
|
2012-09-14 19:16:37 +08:00
|
|
|
wssv.Uri, wssv.Address, wssv.Port);
|
2012-10-01 14:26:31 +08:00
|
|
|
*/
|
2012-09-24 14:01:25 +08:00
|
|
|
|
2012-10-26 13:58:50 +08:00
|
|
|
/// Multi services server
|
2012-09-24 14:01:25 +08:00
|
|
|
var wssv = new WebSocketServer(4649);
|
|
|
|
wssv.AddService<Echo>("/Echo");
|
2012-10-22 13:58:43 +08:00
|
|
|
wssv.AddService<Echo>("/エコー");
|
2012-09-24 14:01:25 +08:00
|
|
|
wssv.AddService<Chat>("/Chat");
|
2012-10-22 13:58:43 +08:00
|
|
|
wssv.AddService<Chat>("/チャット");
|
2012-10-26 13:58:50 +08:00
|
|
|
//wssv.Sweeped = false; // Must be set after any AddService methods done.
|
2012-09-24 14:01:25 +08:00
|
|
|
|
|
|
|
wssv.Start();
|
|
|
|
Console.WriteLine(
|
|
|
|
"WebSocket Server listening on port: {0}\n", wssv.Port);
|
2012-10-01 14:26:31 +08:00
|
|
|
|
2012-08-04 14:51:31 +08:00
|
|
|
|
|
|
|
Console.WriteLine("Press any key to stop server...");
|
|
|
|
Console.ReadLine();
|
|
|
|
|
|
|
|
wssv.Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|