Browse Source

Fix for pull request #113

pull/146/merge
sta 10 years ago
parent
commit
f99112fc2f
  1. 2
      Example2/Program.cs
  2. 2
      Example3/Program.cs
  3. 25
      websocket-sharp/Server/WebSocketBehavior.cs

2
Example2/Program.cs

@ -63,6 +63,8 @@ namespace Example2
"/Chat",
() => new Chat ("Anon#") {
Protocol = "chat",
// To emit a WebSocket.OnMessage event when receives a Ping.
EmitOnPing = true,
// To ignore the Sec-WebSocket-Extensions header.
IgnoreExtensions = true,
// To validate the Origin header.

2
Example3/Program.cs

@ -90,6 +90,8 @@ namespace Example3
"/Chat",
() => new Chat ("Anon#") {
Protocol = "chat",
// To emit a WebSocket.OnMessage event when receives a Ping.
EmitOnPing = true,
// To ignore the Sec-WebSocket-Extensions header.
IgnoreExtensions = true,
// To validate the Origin header.

25
websocket-sharp/Server/WebSocketBehavior.cs

@ -46,6 +46,7 @@ namespace WebSocketSharp.Server
private WebSocketContext _context;
private Func<CookieCollection, CookieCollection, bool> _cookiesValidator;
private bool _emitOnPing;
private string _id;
private bool _ignoreExtensions;
private Func<string, bool> _originValidator;
@ -145,6 +146,29 @@ namespace WebSocketSharp.Server
}
}
/// <summary>
/// Gets or sets a value indicating whether the <see cref="WebSocket"/> used in a session emits
/// a <see cref="WebSocket.OnMessage"/> event when receives a Ping.
/// </summary>
/// <value>
/// <c>true</c> if the <see cref="WebSocket"/> emits a <see cref="WebSocket.OnMessage"/> event
/// when receives a Ping; otherwise, <c>false</c>. The default value is <c>false</c>.
/// </value>
public bool EmitOnPing {
get {
return _websocket != null ? _websocket.EmitOnPing : _emitOnPing;
}
set {
if (_websocket != null) {
_websocket.EmitOnPing = value;
return;
}
_emitOnPing = value;
}
}
/// <summary>
/// Gets the unique ID of a session.
/// </summary>
@ -329,6 +353,7 @@ namespace WebSocketSharp.Server
_websocket = context.WebSocket;
_websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest;
_websocket.EmitOnPing = _emitOnPing;
_websocket.IgnoreExtensions = _ignoreExtensions;
_websocket.Protocol = _protocol;

Loading…
Cancel
Save