Added a new AddWebSocketService method to the WebSocketServer and HttpServer classes
This commit is contained in:
@@ -10,10 +10,21 @@ namespace Example3
|
||||
private static int _num = 0;
|
||||
|
||||
private string _name;
|
||||
private string _prefix;
|
||||
|
||||
public Chat ()
|
||||
: this ("anon#")
|
||||
{
|
||||
}
|
||||
|
||||
public Chat (string prefix)
|
||||
{
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
private string getName ()
|
||||
{
|
||||
return Context.QueryString ["name"] ?? ("anon#" + getNum ());
|
||||
return Context.QueryString ["name"] ?? (_prefix + getNum ());
|
||||
}
|
||||
|
||||
private int getNum ()
|
||||
|
@@ -25,6 +25,7 @@ namespace Example3
|
||||
//_httpsv.KeepClean = false;
|
||||
_httpsv.AddWebSocketService<Echo> ("/Echo");
|
||||
_httpsv.AddWebSocketService<Chat> ("/Chat");
|
||||
//_httpsv.AddWebSocketService<Chat> ("/Chat", () => new Chat ("Anon#"));
|
||||
|
||||
_httpsv.OnGet += (sender, e) =>
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Example3
|
||||
_httpsv.Start ();
|
||||
if (_httpsv.IsListening)
|
||||
{
|
||||
Console.WriteLine ("HTTP Server listening on port: {0} service path:", _httpsv.Port);
|
||||
Console.WriteLine ("An HTTP Server listening on port: {0} service path:", _httpsv.Port);
|
||||
foreach (var path in _httpsv.WebSocketServices.ServicePaths)
|
||||
Console.WriteLine (" {0}", path);
|
||||
|
||||
|
Reference in New Issue
Block a user