public static Communicator Create() { ChannelEventDispatcher.TryInit(); var communicator = new Communicator(); communicator.ChannelFactory.TaskFactory = new UnitySlimTaskFactory { Owner = ChannelEventDispatcher.Instance }; ((ObserverRegistry)communicator.ObserverRegistry).EventPoster = c => ChannelEventDispatcher.Post(c, null); return(communicator); }
public static ChannelFactory Build(IPacketSerializer packetSerializer = null, IPEndPoint endPoint = null, Func <ILog> createChannelLogger = null) { ChannelEventDispatcher.TryInit(); if (packetSerializer == null) { packetSerializer = PacketSerializer.CreatePacketSerializer(); } var channelFactory = new ChannelFactory { Type = ChannelType.Tcp, ConnectEndPoint = endPoint, CreateChannelLogger = createChannelLogger, TaskFactory = new UnitySlimTaskFactory { Owner = ChannelEventDispatcher.Instance }, ObserverEventPoster = c => ChannelEventDispatcher.Post(c, null), PacketSerializer = packetSerializer }; return(channelFactory); }