io.nadron.event.impl.EventDispatchers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadron Show documentation
Show all versions of nadron Show documentation
Nadron is a high speed socket based java game server written using Netty and Mike Rettig's Jetlang. It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.
package io.nadron.event.impl;
import io.nadron.app.GameRoom;
import io.nadron.concurrent.Fibers;
import io.nadron.concurrent.Lane;
import io.nadron.concurrent.LaneStrategy;
import io.nadron.event.Event;
import io.nadron.event.EventDispatcher;
import java.util.concurrent.ExecutorService;
import org.jetlang.channels.MemoryChannel;
import org.jetlang.fibers.Fiber;
public class EventDispatchers
{
public static EventDispatcher newJetlangEventDispatcher(GameRoom room,
LaneStrategy strategy)
{
Fiber fiber = null;
JetlangEventDispatcher dispatcher = null;
if (null == room)
{
fiber = Fibers.pooledFiber();
dispatcher = new JetlangEventDispatcher(new MemoryChannel(),
fiber, null);
}
else
{
Lane lane = strategy.chooseLane(room);
fiber = Fibers.pooledFiber(lane);
dispatcher = new JetlangEventDispatcher(new MemoryChannel(),
fiber, lane);
}
dispatcher.initialize();
return dispatcher;
}
}