[Modify] Polish it

This commit is contained in:
sta 2015-11-27 17:38:37 +09:00
parent ec0ba0a0db
commit b1b728eefd
3 changed files with 9 additions and 11 deletions

View File

@ -24,9 +24,7 @@ namespace Example2
private string getName () private string getName ()
{ {
var name = Context.QueryString["name"]; var name = Context.QueryString["name"];
return !name.IsNullOrEmpty () return !name.IsNullOrEmpty () ? name : _prefix + getNumber ();
? name
: (_prefix + getNumber ());
} }
private static int getNumber () private static int getNumber ()

View File

@ -9,8 +9,7 @@ namespace Example2
protected override void OnMessage (MessageEventArgs e) protected override void OnMessage (MessageEventArgs e)
{ {
var name = Context.QueryString["name"]; var name = Context.QueryString["name"];
var msg = !name.IsNullOrEmpty () ? String.Format ("'{0}' to {1}", e.Data, name) : e.Data; Send (!name.IsNullOrEmpty () ? String.Format ("\"{0}\" to {1}", e.Data, name) : e.Data);
Send (msg);
} }
} }
} }

View File

@ -11,11 +11,11 @@ namespace Example2
{ {
public static void Main (string[] args) public static void Main (string[] args)
{ {
/* Create a new instance of the WebSocketServer class. // Create a new instance of the WebSocketServer class.
* //
* If you would like to provide the secure connection, you should create the instance with // If you would like to provide the secure connection, you should create the instance with
* the 'secure' parameter set to true, or the wss scheme WebSocket URL. // the 'secure' parameter set to true, or the wss scheme WebSocket URL.
*/
var wssv = new WebSocketServer (4649); var wssv = new WebSocketServer (4649);
//var wssv = new WebSocketServer (5963, true); //var wssv = new WebSocketServer (5963, true);
//var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649); //var wssv = new WebSocketServer (System.Net.IPAddress.Parse ("127.0.0.1"), 4649);
@ -62,8 +62,9 @@ namespace Example2
wssv.AddWebSocketService<Chat> ( wssv.AddWebSocketService<Chat> (
"/Chat", "/Chat",
() => new Chat ("Anon#") { () => new Chat ("Anon#") {
// To send the Sec-WebSocket-Protocol header that has a subprotocol name.
Protocol = "chat", Protocol = "chat",
// To emit a WebSocket.OnMessage event when receives a Ping. // To emit a WebSocket.OnMessage event when receives a ping.
EmitOnPing = true, EmitOnPing = true,
// To ignore the Sec-WebSocket-Extensions header. // To ignore the Sec-WebSocket-Extensions header.
IgnoreExtensions = true, IgnoreExtensions = true,