Fix for issue #15

This commit is contained in:
sta
2013-04-06 16:21:41 +09:00
parent cbaa540b59
commit 94cf881dcf
83 changed files with 985 additions and 118 deletions

View File

@@ -30,6 +30,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading;
using WebSocketSharp.Net;
using WebSocketSharp.Net.WebSockets;
namespace WebSocketSharp.Server {
@@ -148,8 +149,14 @@ namespace WebSocketSharp.Server {
if (IsBound)
return;
_context = context;
_sessions = sessions;
if (!ProcessCookies(context.CookieCollection, context.WebSocket.CookieCollection))
{
context.WebSocket.Close(HttpStatusCode.BadRequest);
return;
}
_context = context;
_sessions = sessions;
_websocket = context.WebSocket;
_websocket.OnOpen += onOpen;
@@ -211,6 +218,23 @@ namespace WebSocketSharp.Server {
{
}
/// <summary>
/// Processes the cookies used in the WebSocket opening handshake.
/// </summary>
/// <returns>
/// <c>true</c> if processing the cookies is successfully; otherwise, <c>false</c>.
/// </returns>
/// <param name="request">
/// A <see cref="CookieCollection"/> that contains a collection of the HTTP Cookies received from the client.
/// </param>
/// <param name="response">
/// A <see cref="CookieCollection"/> that contains a collection of the HTTP Cookies to send to the client.
/// </param>
protected virtual bool ProcessCookies(CookieCollection request, CookieCollection response)
{
return true;
}
#endregion
#region Public Methods