public override bool onHandshake() { SyncObject syncObject = null; base.SendMessage(new MsgValidation(Connection.VALIDATION)); if (!(syncObject = base.ReceiveMessage((IMessage message) => { MsgValidation validation = message as MsgValidation; if (validation != null) { return(validation.ValidationSuccess); } return(false); })).Wait <bool>(false, 30000)) { Client.Disconnect(DisconnectReason.TimeOut); Client.onException(new Exception("Handshake went wrong, CHS_Validation"), ErrorType.Core); if (syncObject.TimedOut) { throw new TimeoutException(TimeOutMessage); } throw new Exception("Incorrect signature"); } try { Client.onValidatingComplete(); } catch (Exception ex) { Client.onException(ex, ErrorType.UserLand); } return(true); }
public override bool onHandshake() { if (!base.ReceiveMessage((IMessage message) => { MsgValidation validation = message as MsgValidation; if (validation != null) { if (validation.ValidationKey.Length != Connection.VALIDATION.Length) { return(false); } unsafe { fixed(byte *ptr = validation.ValidationKey, ptr2 = Connection.VALIDATION) { if (NativeMethods.memcmp(ptr, ptr2, (uint)Connection.VALIDATION.Length) == 0) { base.SendMessage(new MsgValidation(true)); return(true); } } } } return(false); }).Wait <bool>(false, 30000)) { Client.Disconnect(DisconnectReason.TimeOut); Client.onException(new Exception("Handshake went wrong, SHS_Validation"), ErrorType.Core); return(false); } Client.onValidatingComplete(); return(true); }