add ws open ip info (local and remote)
This commit is contained in:
parent
ba5ccfcd10
commit
493a7d7a40
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ Backup*
|
||||
_UpgradeReport_Files
|
||||
bin
|
||||
obj
|
||||
.idea
|
||||
|
||||
*.mdb
|
||||
*.pdb
|
||||
|
15
websocket-sharp/OpenEventArgs.cs
Normal file
15
websocket-sharp/OpenEventArgs.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace WebSocketSharp
|
||||
{
|
||||
public class OpenEventArgs : EventArgs
|
||||
{
|
||||
public string LocalIP { get; private set; }
|
||||
public string RemoteIP { get; private set; }
|
||||
public OpenEventArgs(string localIp, string remoteIp)
|
||||
{
|
||||
LocalIP = localIp;
|
||||
RemoteIP = remoteIp;
|
||||
}
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
@ -52,6 +53,11 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using WebSocketSharp.Net;
|
||||
using WebSocketSharp.Net.WebSockets;
|
||||
using AuthenticationSchemes = WebSocketSharp.Net.AuthenticationSchemes;
|
||||
using Cookie = WebSocketSharp.Net.Cookie;
|
||||
using CookieCollection = WebSocketSharp.Net.CookieCollection;
|
||||
using HttpStatusCode = WebSocketSharp.Net.HttpStatusCode;
|
||||
using NetworkCredential = WebSocketSharp.Net.NetworkCredential;
|
||||
|
||||
namespace WebSocketSharp
|
||||
{
|
||||
@ -796,7 +802,7 @@ namespace WebSocketSharp
|
||||
/// <summary>
|
||||
/// Occurs when the WebSocket connection has been established.
|
||||
/// </summary>
|
||||
public event EventHandler OnOpen;
|
||||
public event EventHandler<OpenEventArgs> OnOpen;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1533,8 +1539,11 @@ namespace WebSocketSharp
|
||||
{
|
||||
_inMessage = true;
|
||||
startReceiving ();
|
||||
try {
|
||||
OnOpen.Emit (this, EventArgs.Empty);
|
||||
try
|
||||
{
|
||||
var local = (IPEndPoint) _tcpClient.Client.LocalEndPoint;
|
||||
var remote = (IPEndPoint) _tcpClient.Client.RemoteEndPoint;
|
||||
OnOpen.Emit (this, new OpenEventArgs(local.Address.ToString(), remote.Address.ToString()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.Error (ex.ToString ());
|
||||
|
@ -67,6 +67,7 @@
|
||||
<Compile Include="CloseEventArgs.cs" />
|
||||
<Compile Include="ByteOrder.cs" />
|
||||
<Compile Include="ErrorEventArgs.cs" />
|
||||
<Compile Include="OpenEventArgs.cs" />
|
||||
<Compile Include="WebSocket.cs" />
|
||||
<Compile Include="Server\WebSocketServer.cs" />
|
||||
<Compile Include="Net\AuthenticationSchemes.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user