//onopen事件
protected override void onopen() { string ipaddress = base.sessions.sessions.first().context.userendpoint.tostring();
string ipaddress2 = base.context.userendpoint.tostring(); websocketmain.account++; base.onopen(); }
在onopen事件内,通过
base.sessions.sessions.first().context.userendpoint.tostring();
string ipaddress2 = base.context.userendpoint.tostring();
函数以上两个函数都可以获取到客户端的ip地址及端口号
黄山市民网:https://www.huangshanshimin.com/