Fix for issue #9 - 2
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using WebSocketSharp;
|
||||
using WebSocketSharp.Server;
|
||||
|
||||
@@ -6,8 +7,7 @@ namespace Example2 {
|
||||
|
||||
public class Chat : WebSocketService
|
||||
{
|
||||
private static object _forNum = new object();
|
||||
private static uint _num = 0;
|
||||
private static int _num = 0;
|
||||
|
||||
private string _name;
|
||||
|
||||
@@ -18,12 +18,9 @@ namespace Example2 {
|
||||
: "anon#" + getNum();
|
||||
}
|
||||
|
||||
private uint getNum()
|
||||
private int getNum()
|
||||
{
|
||||
lock (_forNum)
|
||||
{
|
||||
return ++_num;
|
||||
}
|
||||
return Interlocked.Increment(ref _num);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object sender, EventArgs e)
|
||||
|
Binary file not shown.
@@ -20,6 +20,7 @@ namespace Example2
|
||||
//var wssv = new WebSocketServiceHost<Chat>(4649);
|
||||
//var wssv = new WebSocketServiceHost<Chat>(4649, "/Chat");
|
||||
//var wssv = new WebSocketServiceHost<Chat>(4649, "/チャット");
|
||||
//wssv.Sweeped = false; // Stop the Sweep inactive session Timer.
|
||||
|
||||
wssv.Start();
|
||||
Console.WriteLine(
|
||||
@@ -27,12 +28,13 @@ namespace Example2
|
||||
wssv.Uri, wssv.Address, wssv.Port);
|
||||
*/
|
||||
|
||||
// Multi services server
|
||||
/// Multi services server
|
||||
var wssv = new WebSocketServer(4649);
|
||||
wssv.AddService<Echo>("/Echo");
|
||||
wssv.AddService<Echo>("/エコー");
|
||||
wssv.AddService<Chat>("/Chat");
|
||||
wssv.AddService<Chat>("/チャット");
|
||||
//wssv.Sweeped = false; // Must be set after any AddService methods done.
|
||||
|
||||
wssv.Start();
|
||||
Console.WriteLine(
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user