类 HttpRealIpHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.iohao.game.external.core.netty.handler.ws.HttpRealIpHandler
所有已实现的接口:
UserSessionsAware, io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public final class HttpRealIpHandler extends io.netty.channel.ChannelInboundHandlerAdapter implements UserSessionsAware
获取玩家真实 ip
 nginx 配置

 server {
     location /websocket {
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "Upgrade";
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
     }
 }
 
作者:
渔民小镇
日期:
2023-08-16
  • 嵌套类概要

    从接口继承的嵌套类/接口 io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    void
    setUserSessions(UserSessions<?,?> userSessions)
    框架会调用此方法,将 UserSessions 对象传入

    从类继承的方法 io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    从类继承的方法 io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    从接口继承的方法 io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • 构造器详细资料

    • HttpRealIpHandler

      public HttpRealIpHandler()
  • 方法详细资料

    • setUserSessions

      public void setUserSessions(UserSessions<?,?> userSessions)
      从接口复制的说明: UserSessionsAware
      框架会调用此方法,将 UserSessions 对象传入
      指定者:
      setUserSessions 在接口中 UserSessionsAware
      参数:
      userSessions - userSessions
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
      指定者:
      channelRead 在接口中 io.netty.channel.ChannelInboundHandler
      覆盖:
      channelRead 在类中 io.netty.channel.ChannelInboundHandlerAdapter
      抛出:
      Exception