cpw.mods.fml.common.network

## Enum NetworkRegistry

- java.lang.Object
- - java.lang.Enum<NetworkRegistry>
  - - cpw.mods.fml.common.network.NetworkRegistry

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<NetworkRegistry>

      public enum NetworkRegistry
      extends java.lang.Enum<NetworkRegistry>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NetworkRegistry.TargetPoint` Represents a target point for the ALLROUNDPOINT target.

  - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `INSTANCE`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.netty.util.AttributeKey<Side>` | `CHANNEL_SOURCE`
    `static io.netty.util.AttributeKey<java.lang.String>` | `FML_CHANNEL` Set in the `ChannelHandlerContext`
    `static byte` | `FML_PROTOCOL`
    `static io.netty.util.AttributeKey<ModContainer>` | `MOD_CONTAINER`
    `static io.netty.util.AttributeKey<INetHandler>` | `NET_HANDLER`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Set<java.lang.String>` | `channelNamesFor(Side side)` All the valid channel names for a side
    `void` | `fireNetworkHandshake(NetworkDispatcher networkDispatcher, Side origin)` INTERNAL fire a handshake to all channels
    `FMLEmbeddedChannel` | `getChannel(java.lang.String name, Side source)`
    `java.lang.Object` | `getLocalGuiContainer(ModContainer mc, EntityPlayer player, int modGuiId, World world, int x, int y, int z)` INTERNAL method for accessing the Gui registry
    `Container` | `getRemoteGuiContainer(ModContainer mc, EntityPlayerMP player, int modGuiId, World world, int x, int y, int z)` INTERNAL method for accessing the Gui registry
    `boolean` | `hasChannel(java.lang.String channelName, Side source)` Is there a channel with this name on this side?
    `java.util.EnumMap<Side,FMLEmbeddedChannel>` | `newChannel(ModContainer container, java.lang.String name, io.netty.channel.ChannelHandler... handlers)` INTERNAL Create a new channel pair with the specified name and channel handlers.
    `java.util.EnumMap<Side,FMLEmbeddedChannel>` | `newChannel(java.lang.String name, io.netty.channel.ChannelHandler... handlers)` Create a new synchronous message channel pair based on netty.
    `FMLEventChannel` | `newEventDrivenChannel(java.lang.String name)` Construct a new `FMLEventChannel` for the channel.
    `SimpleNetworkWrapper` | `newSimpleChannel(java.lang.String name)` Construct a new `SimpleNetworkWrapper` for the channel.
    `void` | `register(ModContainer fmlModContainer, java.lang.Class<?> clazz, java.lang.String remoteVersionRange, ASMDataTable asmHarvestedData)` INTERNAL method for registering a mod as a network capable thing
    `void` | `registerGuiHandler(java.lang.Object mod, IGuiHandler handler)` Register an `IGuiHandler` for the supplied mod object.
    `java.util.Map<ModContainer,NetworkModHolder>` | `registry()`
    `static NetworkRegistry` | `valueOf(java.lang.String name)` Returns the enum constant of this type with the specified name.
    `static NetworkRegistry[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### INSTANCE

          public static final NetworkRegistry INSTANCE

  - ### Field Detail

    - #### FML_CHANNEL

          public static final io.netty.util.AttributeKey<java.lang.String> FML_CHANNEL

      Set in the `ChannelHandlerContext`

    - #### CHANNEL_SOURCE

          public static final io.netty.util.AttributeKey<Side> CHANNEL_SOURCE

    - #### MOD_CONTAINER

          public static final io.netty.util.AttributeKey<ModContainer> MOD_CONTAINER

    - #### NET_HANDLER

          public static final io.netty.util.AttributeKey<INetHandler> NET_HANDLER

    - #### FML_PROTOCOL

          public static final byte FML_PROTOCOL

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### values

          public static NetworkRegistry[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (NetworkRegistry c : NetworkRegistry.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static NetworkRegistry valueOf(java.lang.String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `java.lang.IllegalArgumentException` - if this enum type has no constant with the specified name
        `java.lang.NullPointerException` - if the argument is null

    - #### newChannel

          public java.util.EnumMap<Side,FMLEmbeddedChannel> newChannel(java.lang.String name,
                                                              io.netty.channel.ChannelHandler... handlers)

      Create a new synchronous message channel pair based on netty. There are two preconstructed models available:
      - `newSimpleChannel(String)` provides `SimpleNetworkWrapper`, a simple implementation of a netty handler, suitable for those who don't wish to dive too deeply into netty.
      - `#newEventChannel(String)` provides `FMLEventChannel` an event driven implementation, with lower level access to the network data stream, for those with advanced bitbanging needs that don't wish to poke netty too hard.
      - Alternatively, simply use the netty features provided here and implement the full power of the netty stack.
      There are two channels created : one for each logical side (considered as the source of an outbound message) The returned map will contain a value for each logical side, though both will only be working in the integrated server case. The channel expects to read and write using `FMLProxyPacket`. All operation is synchronous, as the asynchronous behaviour occurs at a lower level in netty. The first handler in the pipeline is special and should not be removed or moved from the head - it transforms packets from the outbound of this pipeline into custom packets, based on the current `AttributeKey` value `NetworkRegistry#FML_MESSAGETARGET` and `NetworkRegistry#FML_MESSAGETARGETARGS` set on the channel. For the client to server channel (source side : CLIENT) this is fixed as "TOSERVER". For SERVER to CLIENT packets, several possible values exist. Mod Messages should be transformed using a something akin to a `MessageToMessageCodec`. FML provides a utility codec, `FMLIndexedMessageToMessageCodec` that transforms from `FMLProxyPacket` to a mod message using a message discriminator byte. This is optional, but highly recommended for use. Note also that the handlers supplied need to be `ChannelHandler.Shareable` - they are injected into two channels.
      Parameters:
        `name` -
        `handlers` -
      Returns:

    - #### newSimpleChannel

          public SimpleNetworkWrapper newSimpleChannel(java.lang.String name)

      Construct a new `SimpleNetworkWrapper` for the channel.
      Parameters:
        `name` - The name of the channel
      Returns:
        A `SimpleNetworkWrapper` for handling this channel

    - #### newEventDrivenChannel

          public FMLEventChannel newEventDrivenChannel(java.lang.String name)

      Construct a new `FMLEventChannel` for the channel.
      Parameters:
        `name` - The name of the channel
      Returns:
        An `FMLEventChannel` for handling this channel

    - #### newChannel

          public java.util.EnumMap<Side,FMLEmbeddedChannel> newChannel(ModContainer container,
                                                              java.lang.String name,
                                                              io.netty.channel.ChannelHandler... handlers)

      INTERNAL Create a new channel pair with the specified name and channel handlers. This is used internally in forge and FML
      Parameters:
        `container` - The container to associate the channel with
        `name` - The name for the channel
        `handlers` - Some `ChannelHandler` for the channel
      Returns:
        an `EnumMap` of the pair of channels. keys are `Side`. There will always be two entries.

    - #### getChannel

          public FMLEmbeddedChannel getChannel(java.lang.String name,
                                      Side source)

    - #### registerGuiHandler

          public void registerGuiHandler(java.lang.Object mod,
                                IGuiHandler handler)

      Register an `IGuiHandler` for the supplied mod object.
      Parameters:
        `mod` - The mod to handle GUIs for
        `handler` - A handler for creating GUI related objects

    - #### getRemoteGuiContainer

          public Container getRemoteGuiContainer(ModContainer mc,
                                        EntityPlayerMP player,
                                        int modGuiId,
                                        World world,
                                        int x,
                                        int y,
                                        int z)

      INTERNAL method for accessing the Gui registry
      Parameters:
        `mc` - Mod Container
        `player` - Player
        `modGuiId` - guiId
        `world` - World
        `x` - X coord
        `y` - Y coord
        `z` - Z coord
      Returns:
        The server side GUI object (An instance of `Container`)

    - #### getLocalGuiContainer

          public java.lang.Object getLocalGuiContainer(ModContainer mc,
                                              EntityPlayer player,
                                              int modGuiId,
                                              World world,
                                              int x,
                                              int y,
                                              int z)

      INTERNAL method for accessing the Gui registry
      Parameters:
        `mc` - Mod Container
        `player` - Player
        `modGuiId` - guiId
        `world` - World
        `x` - X coord
        `y` - Y coord
        `z` - Z coord
      Returns:
        The client side GUI object (An instance of `GUI`)

    - #### hasChannel

          public boolean hasChannel(java.lang.String channelName,
                           Side source)

      Is there a channel with this name on this side?
      Parameters:
        `channelName` - The name
        `source` - the side
      Returns:
        if there's a channel

    - #### register

          public void register(ModContainer fmlModContainer,
                      java.lang.Class<?> clazz,
                      java.lang.String remoteVersionRange,
                      ASMDataTable asmHarvestedData)

      INTERNAL method for registering a mod as a network capable thing
      Parameters:
        `fmlModContainer` - The fml mod container
        `clazz` - a class
        `remoteVersionRange` - the acceptable remote range
        `asmHarvestedData` - internal data

    - #### registry

          public java.util.Map<ModContainer,NetworkModHolder> registry()

    - #### channelNamesFor

          public java.util.Set<java.lang.String> channelNamesFor(Side side)

      All the valid channel names for a side
      Parameters:
        `side` - the side
      Returns:
        the set of channel names

    - #### fireNetworkHandshake

          public void fireNetworkHandshake(NetworkDispatcher networkDispatcher,
                                  Side origin)

      INTERNAL fire a handshake to all channels
      Parameters:
        `networkDispatcher` - The dispatcher firing
        `origin` - which side the dispatcher is on