/// <summary> /// 生成认证通道 /// </summary> /// <returns></returns> internal byte[] GenerateVerifyConnection(out ushort sessionId) { try { sessionId = (ushort)GetUnusedSocketIndex(); if (sessionId > ushort.MinValue) { // 先加入验证 RemoteHyperSocket remote = new RemoteHyperSocket(sessionId, this, config); SetSocketAtIndex(sessionId, remote); byte[] data = new byte[8]; data[0] = (byte)((UdpPort >> 8) & 0xFF); data[1] = (byte)((UdpPort) & 0xFF); data[2] = (byte)((sessionId >> 8) & 0xFF); data[3] = (byte)((sessionId) & 0xFF); // 认证部分 data[4] = (byte)(data[0] + data[1]); data[5] = (byte)(data[2] + data[3]); data[6] = (byte)(data[0] + data[3]); data[7] = (byte)(data[1] + data[2]); return(data); } } catch (Exception ex) { svrListener.SocketError(ex); } sessionId = 0; return(null); }
public void SocketException(Exception exception) { listener.SocketError(exception); }