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 Example3 {
|
||||
|
||||
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 Example3 {
|
||||
: "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.
@@ -14,6 +14,7 @@ namespace Example3
|
||||
_httpsv = new HttpServer(4649);
|
||||
_httpsv.AddService<Echo>("/Echo");
|
||||
_httpsv.AddService<Chat>("/Chat");
|
||||
//_httpsv.Sweeped = false; // Must be set after any AddService methods done.
|
||||
|
||||
_httpsv.OnGet += (sender, e) =>
|
||||
{
|
||||
|
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