Refactored a few for EndPointListener.cs

This commit is contained in:
sta 2015-01-02 17:19:28 +09:00
parent 9afa878678
commit b73a95df8f

View File

@ -8,7 +8,7 @@
* The MIT License * The MIT License
* *
* Copyright (c) 2005 Novell, Inc. (http://www.novell.com) * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
* Copyright (c) 2012-2014 sta.blockhead * Copyright (c) 2012-2015 sta.blockhead
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -233,7 +233,7 @@ namespace WebSocketSharp.Net
private static void onAccept (object sender, EventArgs e) private static void onAccept (object sender, EventArgs e)
{ {
var args = (SocketAsyncEventArgs) e; var args = (SocketAsyncEventArgs) e;
var listener = (EndPointListener) args.UserToken; var lsnr = (EndPointListener) args.UserToken;
Socket sock = null; Socket sock = null;
if (args.SocketError == SocketError.Success) { if (args.SocketError == SocketError.Success) {
@ -243,7 +243,7 @@ namespace WebSocketSharp.Net
var res = true; var res = true;
try { try {
res = listener._socket.AcceptAsync (args); res = lsnr._socket.AcceptAsync (args);
} }
catch { catch {
if (sock != null) if (sock != null)
@ -253,7 +253,7 @@ namespace WebSocketSharp.Net
} }
if (sock != null) if (sock != null)
processAccepted (sock, listener); processAccepted (sock, lsnr);
if (!res) if (!res)
onAccept (sender, args); onAccept (sender, args);
@ -427,11 +427,11 @@ namespace WebSocketSharp.Net
public bool BindContext (HttpListenerContext context) public bool BindContext (HttpListenerContext context)
{ {
HttpListenerPrefix pref; HttpListenerPrefix pref;
var listener = searchListener (context.Request.Url, out pref); var lsnr = searchListener (context.Request.Url, out pref);
if (listener == null) if (lsnr == null)
return false; return false;
context.Listener = listener; context.Listener = lsnr;
context.Connection.Prefix = pref; context.Connection.Prefix = pref;
return true; return true;