public async Task <bool> OnHandle(MessageContext context, NotifyServerConnectionRequestDataMessage message) { var session = context.Session; session.Logger.Verbose("Handshake:NotifyServerConnectionRequestData"); if (message.InternalNetVersion != Constants.NetVersion || message.Version != _networkOptions.Version) { // ReSharper disable RedundantAnonymousTypePropertyName session.Logger.Warning( "Protocol version mismatch - Client={@ClientVersion} Server={@ServerVersion}", new { NetVersion = message.InternalNetVersion, Version = message.Version }, new { NetVersion = Constants.NetVersion, Version = _networkOptions.Version }); // ReSharper restore RedundantAnonymousTypePropertyName session.Send(new NotifyProtocolVersionMismatchMessage()); var _ = session.CloseAsync(); } _sessionManager.AddSession(session.HostId, session); session.HandhsakeEvent.Set(); session.State = SessionState.Connected; session.Send(new NotifyServerConnectSuccessMessage( session.HostId, _networkOptions.Version, session.RemoteEndPoint) ); return(true); }
public void NotifyServerConnectionRequestDataMessage(ProudSession session, NotifyServerConnectionRequestDataMessage message) { session.Logger?.Verbose("Handshake:NotifyServerConnectionRequestData"); if (message.InternalNetVersion != Constants.NetVersion || message.Version != _server.Configuration.Version) { session.Logger?.Warning("Protocol version mismatch - Client={@ClientVersion} Server={@ServerVersion}", new { NetVersion = message.InternalNetVersion, message.Version }, new { Constants.NetVersion, _server.Configuration.Version }); session.SendAsync(new NotifyProtocolVersionMismatchMessage()); session.CloseAsync(); return; } _server.AddSession(session); session.HandhsakeEvent.Set(); session.SendAsync(new NotifyServerConnectSuccessMessage(session.HostId, _server.ServerInstanceGuid, session.RemoteEndPoint)); }
public async Task NotifyServerConnectionRequestDataMessage(ProudSession session, NotifyServerConnectionRequestDataMessage message) { if (message.InternalNetVersion != ProudConfig.InternalNetVersion || message.Version != _filter.Config.Version) { await session.SendAsync(new NotifyProtocolVersionMismatchMessage()) .ConfigureAwait(false); session.Close(); return; } IPEndPoint ip; var processor = session.Transport as TcpTransport; if (processor != null) { ip = (IPEndPoint)processor.Socket.RemoteEndPoint; } else { ip = new IPEndPoint(0, 0); } var hostId = await _filter.GetNextHostIdAsync().ConfigureAwait(false); session.HostId = hostId; _filter.SessionLookupByHostId.TryAdd(session.HostId, session); session.ReadyEvent.Set(); await session.SendAsync(new NotifyServerConnectSuccessMessage(hostId, _filter.Config.Version, ip)) .ConfigureAwait(false); }
public void NotifyServerConnectionRequestDataMessage(IChannelHandlerContext context, ProudSession session, NotifyServerConnectionRequestDataMessage message) { if (message.InternalNetVersion != Constants.NetVersion || message.Version != _server.Configuration.Version) { session.SendAsync(new NotifyProtocolVersionMismatchMessage()); session.CloseAsync(); return; } _server.AddSession(session); session.HandhsakeEvent.Set(); session.SendAsync(new NotifyServerConnectSuccessMessage(session.HostId, _server.Configuration.Version, session.RemoteEndPoint)); }